Commit a3ac9596 by 李传峰

Merge branch 'feature/1007143' into 'release'

feat: [1007143] RAYS码配置一个资源的时候跳转逻辑从前端改到后端

See merge request rays/pcloud-book!1575
parents 760a4778 f903e05b
......@@ -311,4 +311,9 @@ public interface BookGroupService {
@ApiOperation("二维码企微落地页是否配了内容")
@PostMapping("mapWxworkStateBySceneIds")
ResponseEntity<ResponseDto<Map<Long, Boolean>>> mapWxworkStateBySceneIds(@RequestBody List<Long> sceneIds);
@ApiOperation("获取只配置一个资源的跳转地址")
@GetMapping("getQrcodeOneServe")
public ResponseEntity<ResponseDto<String>> getQrcodeOneServe(@RequestParam(value = "bookGroupId", required = false) Long bookGroupId,
@RequestParam(value = "sceneId", required = false) Long sceneId);
}
......@@ -750,4 +750,20 @@ public class QrcodeSceneConsr {
}
return null;
}
/**
* 修改二维码是否符合一个资源直接跳转
*/
public void updateQrcodeOneServeRule(Long sceneId, Integer isOneServeJump, String serveJumpUrl, Long serveRuleVersion) throws BizException {
if (sceneId == null) {
return;
}
try {
qrcodeSceneService.updateQrcodeOneServeRule(sceneId, isOneServeJump,serveJumpUrl,serveRuleVersion);
} catch (BizException e) {
LOGGER.warn("【修改二维码是否符合一个资源直接跳转,<ERROR>.[qrcodeSceneService.updateQrcodeOneServeRule]:" + e.getMessage(), e);
} catch (Exception e) {
LOGGER.error("【修改二维码是否符合一个资源直接跳转,<ERROR>.[qrcodeSceneService.updateQrcodeOneServeRule]:" + e.getMessage(), e);
}
}
}
......@@ -133,6 +133,10 @@ public interface ResourcePageBiz {
*/
Long updateResourcePageAndColumn(UpdateResourcePageVO updateResourcePageVO);
public String getQrcodeOneServe(Long bookGroupId,Long sceneId,Boolean ignoreRays);
void updateQrcodeOneServe(Long bookGroupId,Long sceneId,Boolean ignoreRays);
/**
* 客户端根据rays码id查资源页基本配置
* @author:zhuyajie
......
......@@ -107,7 +107,9 @@ import com.pcloud.book.group.entity.ResourcePageShare;
import com.pcloud.book.group.entity.ResourcePageTool;
import com.pcloud.book.group.entity.ResourcePageWxwork;
import com.pcloud.book.group.entity.ResourceRecomManage;
import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.group.enums.PageLandingPageTypeEnum;
import com.pcloud.book.group.enums.QrcodeJumpType;
import com.pcloud.book.group.enums.ResourcePageFixtureTypeEnum;
import com.pcloud.book.group.mapper.ResourcePageShareMapper;
import com.pcloud.book.group.tools.SendWeixinRequestTools;
......@@ -175,6 +177,8 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
......@@ -202,8 +206,23 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.cron.pattern.CronPatternUtil;
import cn.hutool.extra.qrcode.QrCodeException;
import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import static com.pcloud.book.group.constant.ResourcePageConstants.DL_BOOK_SERVES_CACHE;
/**
......@@ -217,6 +236,8 @@ import static com.pcloud.book.group.constant.ResourcePageConstants.DL_BOOK_SERVE
@Slf4j
public class ResourcePageBizImpl implements ResourcePageBiz {
private static final Logger LOGGER = LoggerFactory.getLogger(ResourcePageBizImpl.class);
@Autowired
private ResourcePageDao resourcePageDao;
@Autowired
......@@ -331,7 +352,11 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
private Long nftSceneId;
@Value("${nft.bookGroupId}")
private Long nftBookGroupId;
@Value("${system.env}")
private String envStr;
public static final String nftReleaseLockKey = "CHANNELCENTER:NFT:RELEASE";
@Value("${one_serve_rule_version}")
private Long oneServeRuleVersion;
@Override
public Long updateResourcePage(UpdateResourcePageVO updateResourcePageVO) {
......@@ -449,6 +474,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
this.updateResourcePageModel(resourcePage.getId(),updateResourcePageVO.getResourcePageModelList(),resourcePage.getCreateUser());
Long resourcePageId = resourcePage.getId();
ThreadPoolUtils.OTHER_THREAD_POOL.execute(()-> esBookAndAdviserBiz.updateBookAndAdviserToES(Collections.singletonList(resourcePageId)));
//更新二维码是否一个资源配置
// ThreadPoolUtils.OTHER_POOL.execute(()->{
this.updateQrcodeOneServe(updateResourcePageVO.getBookGroupId(),updateResourcePageVO.getSceneId(),null);
// });
return resourcePage.getId();
}
......@@ -555,6 +584,10 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
this.updateResourcePageModel(resourcePage.getId(),updateResourcePageVO.getResourcePageModelList(),resourcePage.getCreateUser());
Long resourcePageId = resourcePage.getId();
ThreadPoolUtils.OTHER_THREAD_POOL.execute(()-> esBookAndAdviserBiz.updateBookAndAdviserToES(Collections.singletonList(resourcePageId)));
//更新二维码是否一个资源配置
// ThreadPoolUtils.OTHER_POOL.execute(()->{
this.updateQrcodeOneServe(updateResourcePageVO.getBookGroupId(),updateResourcePageVO.getSceneId(),null);
// });
return resourcePage.getId();
}
......@@ -1693,8 +1726,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
}
itemVO.setChannelId(channelId);
setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap);
if (null != wechatUserId) {
setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap);
itemVO.setBuyState(false);
if (!MapUtils.isEmpty(buyStateMap)) {
if(ResourcePageConstants.ServeTypeEnum.PRODUCT.getValue().equals(serveType)){
......@@ -2057,9 +2090,206 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
//删除缓存
JedisClusterUtils.del("FUNCTION:DOULUO_APP");
JedisClusterUtils.del(DL_BOOK_SERVES_CACHE + updateResourcePageVO.getSceneId());
//updateQrcodeOneServe(updateResourcePageVO);
//更新二维码是否一个资源配置,异步会有时候没能及时更新。如果非要异步。线程先休息2s再执行
//ThreadPoolUtils.OTHER_POOL.execute(()->{
this.updateQrcodeOneServe(updateResourcePageVO.getBookGroupId(),updateResourcePageVO.getSceneId(),null);
// });
return resourcePageId;
}
@Override
public void updateQrcodeOneServe(Long bookGroupId, Long sceneId, Boolean ignoreRays) {
String jumpUrl = getQrcodeOneServe(bookGroupId, sceneId, ignoreRays);
Integer isOneServeJump=0;
if(StrUtil.isNotBlank(jumpUrl)){
isOneServeJump=1;
}
qrcodeSceneConsr.updateQrcodeOneServeRule(sceneId,isOneServeJump,jumpUrl,oneServeRuleVersion);
}
@Override
public String getQrcodeOneServe(Long bookGroupId,Long sceneId,Boolean ignoreRays) {
String jumpUrl= null;
try {
if(null==ignoreRays){
ignoreRays=true;
}
// 1007143 判断逻辑见hasOneResource接口
// 满足以下条件则进入自动跳转流程
/* reslut.navigationJumpType !== 2 && // 菜单类型不是2
data.oneServe && // 只有一个资源
data.resultUrl && // 这个资源有跳转地址
!qrcodeInfo.isDisable && // 当前二维码不是禁用状态
codeUseStatus === 1 && // 授权码状态为1
!raysToolCodeArr.includes(data.typeCode) && // 该应用不是rays工具*/
//因为在hasOneResource方法中没有wechatuserId在填充资源信息的时候会跳过。所以要有一个。
ResourcePageOneServe oneServe = hasOneResource(bookGroupId, sceneId, 0L, ignoreRays);
//此处授权码状态为1,只能放到前端校验。因为需要先授权。所以这一类的二维码在渠道分发跳转要提出来还是跳转到落地页
//菜单类型不是2 && 只有一个资源 && 这个资源有跳转地址
if(null!=oneServe.getOneServe() && oneServe.getOneServe() && null!=oneServe.getNavigationJumpType() && oneServe.getNavigationJumpType() != 2
&& StrUtil.isNotBlank(oneServe.getResultUrl())){
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneConsr.getOnlySceneInfoById(sceneId);
//当前二维码不是禁用状态
if(null!=qrcodeSceneDto && null!=qrcodeSceneDto.getIsDisable() && qrcodeSceneDto.getIsDisable()==0){
//该应用不是rays工具
List<String> typeCodes = appConsr.getRaysAppTypeCodes();
if(CollUtil.isEmpty(typeCodes) || (null!=oneServe.getTypeCode() && !typeCodes.contains(oneServe.getTypeCode()))){
//更新
jumpUrl=oneServe.getResultUrl();
// url处理
// 是否做url处理
Boolean isTransfer =false;
if(null!=oneServe.getHasOfficialAccountsTool()){
isTransfer=!oneServe.getHasOfficialAccountsTool();
}
//前端代码
/*if(bookGroupId && data.jumpType === 7) {
isTransfer = false;
}*/
if(null!=oneServe.getJumpType() && oneServe.getJumpType() == 7) {
if(isGroupId(bookGroupId)) {
isTransfer = false;
}
}
// qrcodeType === 'ali' 原有自有码 own下面的RAYS码,不作处理
if(null!=oneServe.getQrcodeType() && "ali".equalsIgnoreCase(oneServe.getQrcodeType())) {
isTransfer = false;
}
// 化学工业出版社有限公司,只配置一个文章类型的 链接不做处理
if(null!=oneServe.getTypeCode() && "ARTICLE".equalsIgnoreCase(oneServe.getTypeCode()) && oneServe.getAdviserId()!=null && oneServe.getAdviserId()== 1000021984L) {
isTransfer = false;
}
jumpUrl = getServiceWebviewUrl(jumpUrl, isTransfer);
}
}
}
} catch (BizException e) {
LOGGER.warn("判断是否符合二维码一个资源逻辑失败"+e.getMsg());
}
return jumpUrl;
}
public Boolean isGroupId(Long bookGroupId){
Boolean isGroup=false;
if(null==bookGroupId){
return false;
}
//根据joinGroupType判断二维码类型
Map<String, Object> map = bookGroupBiz.getBookNameByBookGroupId(bookGroupId);
Boolean isDelete = (Boolean) map.get("isDelete");
if (isDelete) {
return false;
}
Integer joinGroupType = (Integer) map.get("joinGroupType");
if (JoinGroupTypeEnum.XIAORUI.getCode().equals(joinGroupType)) {
Integer jumpType = (Integer) map.get("jumpType");
//自定义链接
if (QrcodeJumpType.H5_SELF_URL.getCode().equals(jumpType)) {
if (null != map.get("jumpUrl")) {
return false;
}
}
return true;
}
return isGroup;
}
public String getServiceWebviewUrl(String url, Boolean isTransfer) {
if(null==isTransfer){
isTransfer=true;
}
Long originAccountId=null;
String accountString = ReUtil.get("W(\\d*)", url, 0);
if (StrUtil.isNotBlank(accountString)) {
String w = accountString.replaceAll("W", "");
if(null!=w && NumberUtil.isNumber(w)){
originAccountId = Long.valueOf(w);
}
}
// url拼接 加traceId。放到渠道分发里面做。
// 无须更换域名
if(!isTransfer) {
return url;
}
//小蓝书支付跳转到自己的商户号,不做处理
List<Long> xiaoLanShuList = CollUtil.toList(65777L, 65842L, 65957L, 65961L, 66046L, 66047L, 66049L, 66050L, 66069L, 66070L, 66076L, 66078L, 66079L, 66107L, 66134L);
if(xiaoLanShuList.contains(originAccountId)) {
return url;
}
//阿法迪支付到自己的商户号
if(null!=originAccountId && originAccountId == 66043L) {
String productDomain = "https://weixin76043.raystime.com/";
if(isRaysLink(url)) {
url = aFaDiExchangeLinkDomain(url, productDomain,null);
}
} else {
// 如果链接是rays链接
if(isRaysLink(url)) {
url = exchangeLinkDomain(url, getProductDomain(),null);
}
}
return url;
}
// 是不是rays链接
public Boolean isRaysLink(String url) {
return ReUtil.contains("^(https|http?)://weixin\\w+[.]",url) || ReUtil.contains("^(https|http?)://(app\\w*)[.]",url);
}
public static final String DOMAIN_REG = "^(https|http?)://([a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?\\.)+[a-zA-Z]{2,6}(\\/)";
// 阿法迪单独特殊处理(临时方案)
public String aFaDiExchangeLinkDomain(String url,String domain,Boolean isReplaceAccountId) {
if(null==isReplaceAccountId){
isReplaceAccountId=true;
}
Long officialAccountId = 66043L;
if(!domain.endsWith("/")) {
domain += '/';
}
url = ReUtil.replaceAll(url, DOMAIN_REG, domain);
return isReplaceAccountId ? url.replace("/W(d\\*)/", "/W${"+officialAccountId+"}/") : url;
}
// url处理
public String exchangeLinkDomain(String url,String domain,Boolean isReplaceAccountId) {
if(null==isReplaceAccountId){
isReplaceAccountId=true;
}
if(!domain.endsWith("/")) {
domain += '/';
}
url = ReUtil.replaceAll(url, DOMAIN_REG, domain);
// OFFICIAL_ACCOUNT_ID 测试23, uat35515, 生产23
return isReplaceAccountId ? url.replace("/W(d\\*)/", "/W${"+getOffAccount()+"}/") : url;
}
public Long getOffAccount(){
if ("pro".equals(envStr)) {
return 23L;
} else if ("uat".equalsIgnoreCase(envStr)) {
return 35515L;
} else if ("test".equalsIgnoreCase(envStr)) {
return 23L;
}
return 23L;
}
public String getProductDomain(){
if ("pro".equals(envStr)) {
return "https://weixin23.5rs.me";
} else if ("uat".equalsIgnoreCase(envStr)) {
return "https://weixin35515.raysyun.com";
} else if ("test".equalsIgnoreCase(envStr)) {
return "https://weixin23.raysgo.com";
}
return null;
}
// 更新图书封面
private void updateBookCover(ResourcePage page, UpdateResourcePageVO updateResourcePageVO) {
if (StrUtil.isNotBlank(updateResourcePageVO.getBookCover()) && Objects.nonNull(page)) {
......@@ -2508,6 +2738,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
Long resourcePageId = resourcePage.getId();
pageOneServe.setResourcePageId(resourcePageId);
pageOneServe.setAdviserId(resourcePage.getCreateUser());
pageOneServe.setNavigationJumpType(resourcePage.getNavigationJumpType());
//只配置了1个应用作品,且不开启小睿
ResourcePageItemVO itemVO = resourcePageItemDao.checkOneServeItemByPageId(resourcePageId, ignoreRays);
if (null != itemVO) {
......
......@@ -189,6 +189,12 @@ public class ResourcePageFacade {
return new ResponseDto<>(resourcePageBiz.updateResourcePageAndColumn(updateResourcePageVO));
}
@GetMapping("getQrcodeOneServe")
public ResponseDto<?> getQrcodeOneServe(@RequestParam(value = "bookGroupId", required = false) Long bookGroupId,
@RequestParam(value = "sceneId", required = false) Long sceneId) {
return new ResponseDto<>(resourcePageBiz.getQrcodeOneServe(bookGroupId,sceneId,null));
}
@ApiOperation("客户端-根据rays码id查资源页基本配置")
@GetMapping("getResourcePageByBookGroupId4Wechat")
public ResponseDto<?> getResourcePageByBookGroupId4Wechat(@CookieValue("userInfo") String userInfo,
......
......@@ -528,4 +528,11 @@ public class BookGroupServiceImpl implements BookGroupService {
public ResponseEntity<ResponseDto<Map<Long, Boolean>>> mapWxworkStateBySceneIds(@RequestBody List<Long> sceneIds) {
return ResponseHandleUtil.toResponse(resourcePageBiz.mapWxworkStateBySceneIds(sceneIds));
}
@Override
@GetMapping("getQrcodeOneServe")
public ResponseEntity<ResponseDto<String>> getQrcodeOneServe(@RequestParam(value = "bookGroupId", required = false) Long bookGroupId,
@RequestParam(value = "sceneId", required = false) Long sceneId) {
return ResponseHandleUtil.toResponse(resourcePageBiz.getQrcodeOneServe(bookGroupId,sceneId,null));
}
}
......@@ -59,4 +59,9 @@ public class ResourcePageOneServe extends BaseDto {
private Boolean hasOfficialAccountsTool;
private Long adviserId;
/**
* 导航使用场景;1:菜单切换;2:功能跳转
*/
private Integer navigationJumpType;
}
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