Commit 39abf6e7 by 朱亚洁

feat:[1006821]getResourcePageByBookGroupId4Wechat

parent 420cdcf7
......@@ -8,7 +8,6 @@ import com.pcloud.advertising.advertising.dto.AdvertisingSpaceDTO;
import com.pcloud.advertising.advertising.dto.AdvertisingSpaceItemDTO;
import com.pcloud.analysisengine.browse.dto.BrowseRecordStatisticDTO;
import com.pcloud.appcenter.app.dto.AppDto;
import com.pcloud.appcenter.app.dto.app.MapBaseStatusDTO;
import com.pcloud.book.applet.biz.AppletBooklistBiz;
import com.pcloud.book.applet.biz.AppletGroupSearchRecordBiz;
import com.pcloud.book.applet.biz.AppletRecordAggrStatisBiz;
......@@ -176,15 +175,13 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.security.auth.callback.CallbackHandler;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.FileUtil;
......@@ -1949,45 +1946,67 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
if (null == bookGroupId && null == sceneId) {
throw new BookBizException(BookBizException.PARAM_IS_NULL,"参数缺失");
}
ResourcePage bySceneId = null;
Long bookId = null;
if (null != bookGroupId) {
bySceneId = resourcePageDao.getByBookGroupId(bookGroupId);
bookId = resourcePageDao.getBookIdByBookGroupId(bookGroupId);
} else if (null != sceneId) {
bySceneId = resourcePageDao.getBySceneId(sceneId);
bookId = resourcePageDao.getBookIdBySceneId(sceneId);
}
//上邮临时处理方案
if (null != bySceneId && null != bySceneId.getBookId() && null != JedisClusterUtils.hget(nftReleaseLockKey, bySceneId.getBookId().toString())) {
if (null != bookId && null != JedisClusterUtils.hget(nftReleaseLockKey, bookId.toString())) {
if (null != bookGroupId) {
bookGroupId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bySceneId.getBookId().toString(), NftBookState.class).getNftBookGroupId();
bookGroupId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bookId.toString(), NftBookState.class).getNftBookGroupId();
} else if (null != sceneId) {
sceneId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bySceneId.getBookId().toString(), NftBookState.class).getNftSceneId();;
sceneId = JedisClusterUtils.hgetJson2Class(nftReleaseLockKey, bookId.toString(), NftBookState.class).getNftSceneId();;
}
}
ResourcePageVO resourcePageVO = new ResourcePageVO();
ResourcePageVO pageVO = new ResourcePageVO();
if (null != bookGroupId) {
resourcePageVO = getResourcePageByBookGroupId4Wechat(bookGroupId, wechatUserId);
pageVO = getResourcePageByBookGroupId4Wechat(bookGroupId, wechatUserId);
} else if (null != sceneId) {
resourcePageVO = getResourcePageBySceneId4Wechat(sceneId);
pageVO = getResourcePageBySceneId4Wechat(sceneId);
}
ResourcePageVO resourcePageVO = pageVO;
if (null != resourcePageVO.getId()) {
//查收藏状态
ResourcePageCollect collect = resourcePageCollectDao.getCollectRecordByUser(wechatUserId, resourcePageVO.getId());
resourcePageVO.setCollectState(null == collect ? 0 : 1);
// 实体店铺
resourcePageVO.setResourcePageBookstoreList(resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.BOOKSTORE));
// 优惠券
resourcePageVO.setResourcePageCouponList(resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.COUPONS));
} else {
resourcePageVO.setResourcePageBookstoreList(CollUtil.toList());
resourcePageVO.setResourcePageCouponList(CollUtil.toList());
}
if (null != resourcePageVO.getAdviserId()) {
resourcePageVO.setPushTextOpenStatus(qrcodeSceneConsr.getPushTextOpenStatus(resourcePageVO.getAdviserId()));
Integer collectState = resourcePageCollectDao.getCollectStateByUser(wechatUserId, resourcePageVO.getId());
resourcePageVO.setCollectState(null == collectState ? 0 : 1);
}
// 实体店铺
CompletableFuture<List<ResourcePageBookstoreVO>> storeFuture = CompletableFuture.supplyAsync(() -> {
return resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.BOOKSTORE);
});
// 优惠券
CompletableFuture<List<ResourcePageBookstoreVO>> couponFuture = CompletableFuture.supplyAsync(() -> {
return resourcePageBookstoreBiz.getByResourcePageId(resourcePageVO.getId(), resourcePageVO.getChannelId(), wechatUserId, ResourcePageFixtureTypeEnum.COUPONS);
});
//加载导航
this.fillNavigation(resourcePageVO, wechatUserId);
CompletableFuture<Void> navigationFuture = CompletableFuture.runAsync(() -> {
this.fillNavigation(resourcePageVO, wechatUserId);
});
//加载企业微信落地页信息
this.fillWxworkPage(resourcePageVO);
CompletableFuture<Void> wxworkPageFuture = CompletableFuture.runAsync(() -> {
this.fillWxworkPage(resourcePageVO);
});
//扫码推送二维码名称权限状态
CompletableFuture<Integer> pushTextFuture = CompletableFuture.supplyAsync(() -> {
return qrcodeSceneConsr.getPushTextOpenStatus(resourcePageVO.getAdviserId());
});
CompletableFuture.allOf(storeFuture, couponFuture, navigationFuture, wxworkPageFuture, pushTextFuture).join();
List<ResourcePageBookstoreVO> bookstoreVOS = new ArrayList<>();
List<ResourcePageBookstoreVO> couponVOS = new ArrayList<>();
Integer pushTextPermission = 0;
try {
bookstoreVOS = storeFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
couponVOS = couponFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
pushTextPermission = pushTextFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("查询实体店铺/优惠券失败"+e.getMessage(),e);
}
resourcePageVO.setResourcePageBookstoreList(bookstoreVOS);
resourcePageVO.setResourcePageCouponList(couponVOS);
resourcePageVO.setPushTextOpenStatus(pushTextPermission);
return resourcePageVO;
}
......@@ -2021,8 +2040,8 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
resourcePageVO.setLastReadTime(DateUtils.formatDate(new Date()));
//小程序
BookAppletScene bookAppletScene = bookAppletSceneDao.getByBookGroupId(bookGroupId);
resourcePageVO.setAppletId(null == bookAppletScene ? null : bookAppletScene.getAppletId());
String appletId = bookAppletSceneDao.getAppletIdByBookGroupId(bookGroupId);
resourcePageVO.setAppletId(appletId);
ResourcePage resourcePage = resourcePageDao.getByBookGroupId(bookGroupId);
if (null != resourcePage) {
resourcePageVO.setShowBook(resourcePage.getShowBook());
......@@ -2048,35 +2067,9 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
private ResourcePageVO getResourcePageBySceneId4Wechat(Long sceneId) {
ResourcePageVO resourcePageVO = new ResourcePageVO();
resourcePageVO.setSceneId(sceneId);
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = qrcodeSceneConsr.listBaseInfoByIds(Arrays.asList(sceneId));
if (!MapUtils.isEmpty(qrcodeSceneDtoMap) && qrcodeSceneDtoMap.containsKey(sceneId)) {
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(sceneId);
Long bookId = qrcodeSceneDto.getAdviserBookId();
Long adviserId = qrcodeSceneDto.getCreatedByUserLogin();
Long channelId = qrcodeSceneDto.getChannelPartyId();
resourcePageVO.setBookId(bookId);
resourcePageVO.setAdviserId(adviserId);
resourcePageVO.setChannelId(channelId);
resourcePageVO.setQrcodeName(qrcodeSceneDto.getSceneName());
if (null != bookId) {
BookDto bookDto = bookBiz.getBaseById(bookId);
if (null != bookDto) {
resourcePageVO.setBookImg(bookDto.getCoverImg());
resourcePageVO.setBookName(bookDto.getBookName());
}
}
Map<Long, AdviserBaseInfoDto> agentMap = adviserConsr.getAdviserId2AdviserInfoDtoMap(Arrays.asList(adviserId));
if (!MapUtils.isEmpty(agentMap)) {
resourcePageVO.setAgentName(Optional.ofNullable(agentMap.get(adviserId)).orElseGet(AdviserBaseInfoDto::new).getAgentName());
}
AccountSettingDto accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
if(accountSettingDto != null){
resourcePageVO.setAccountSettingId(accountSettingDto.getAccountSettingId());
}
}
//小程序
BookAppletScene bookAppletScene = bookAppletSceneDao.getBySceneId(sceneId);
resourcePageVO.setAppletId(null == bookAppletScene?null:bookAppletScene.getAppletId());
Future<Map<Long, QrcodeSceneDto>> qrcodeFuture = ThreadPoolUtils.RESOURCE_POOL.submit(()->{
return qrcodeSceneConsr.listBaseInfoByIds(Arrays.asList(sceneId));
});
ResourcePage resourcePage = resourcePageDao.getBySceneId(sceneId);
if (null != resourcePage) {
resourcePageVO.setShowBook(resourcePage.getShowBook());
......@@ -2097,6 +2090,54 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
resourcePageVO.setNavigationJumpType(resourcePage.getNavigationJumpType());
resourcePageVO.setIsShowPrice(resourcePage.getIsShowPrice());
}
//小程序
resourcePageVO.setAppletId(bookAppletSceneDao.getAppletIdBySceneId(sceneId));
Map<Long, QrcodeSceneDto> qrcodeSceneDtoMap = new HashMap<>();
try {
qrcodeSceneDtoMap = qrcodeFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT,TimeUnit.SECONDS);
}catch (Exception e) {
log.error("查二维码失败"+e.getMessage(),e);
}
if (!MapUtils.isEmpty(qrcodeSceneDtoMap) && qrcodeSceneDtoMap.containsKey(sceneId)) {
QrcodeSceneDto qrcodeSceneDto = qrcodeSceneDtoMap.get(sceneId);
Long bookId = qrcodeSceneDto.getAdviserBookId();
resourcePageVO.setBookId(bookId);
resourcePageVO.setAdviserId(qrcodeSceneDto.getCreatedByUserLogin());
resourcePageVO.setChannelId(qrcodeSceneDto.getChannelPartyId());
resourcePageVO.setQrcodeName(qrcodeSceneDto.getSceneName());
if (null != bookId) {
BookDto bookDto = bookBiz.getBaseById(bookId);
if (null != bookDto) {
resourcePageVO.setBookImg(bookDto.getCoverImg());
resourcePageVO.setBookName(bookDto.getBookName());
}
}
}
Long adviserId = resourcePageVO.getAdviserId();
CompletableFuture<Map<Long, AdviserBaseInfoDto>> agentFuture = CompletableFuture.supplyAsync(() -> {
return adviserConsr.getAdviserId2AdviserInfoDtoMap(null == adviserId?new ArrayList<>():Arrays.asList(adviserId));
});
CompletableFuture<AccountSettingDto> accountSettingFuture = CompletableFuture.supplyAsync(() -> {
return qrcodeSceneConsr.getWechatInfo(resourcePageVO.getChannelId());
});
CompletableFuture.allOf(agentFuture, accountSettingFuture).join();
Map<Long, AdviserBaseInfoDto> agentMap = new HashMap<>();
AccountSettingDto accountSettingDto = new AccountSettingDto();
try {
agentMap = agentFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT,TimeUnit.SECONDS);
accountSettingDto = accountSettingFuture.get(ThreadPoolUtils.REMOTE_TIME_OUT,TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("查询出版社/公众号失败"+e.getMessage(),e);
}
if (!MapUtils.isEmpty(agentMap)) {
resourcePageVO.setAgentName(Optional.ofNullable(agentMap.get(adviserId)).orElseGet(AdviserBaseInfoDto::new).getAgentName());
}
if(accountSettingDto != null){
resourcePageVO.setAccountSettingId(accountSettingDto.getAccountSettingId());
}
return resourcePageVO;
}
......
......@@ -99,6 +99,9 @@ public class ResourcePageBookstoreBizImpl implements ResourcePageBookstoreBiz {
@Override
public List<ResourcePageBookstoreVO> getByResourcePageId(Long resourcePageId, Long channelId, Long wechatUserId, ResourcePageFixtureTypeEnum fixtureTypeEnum) {
if (null == resourcePageId) {
return CollUtil.toList();
}
List<ResourcePageBookstoreVO> list = resourcePageBookstoreDao.getByResourcePageId(resourcePageId, fixtureTypeEnum.fixtureType);
if(CollUtil.isEmpty(list)){
return CollUtil.toList();
......
......@@ -55,4 +55,8 @@ public interface BookAppletSceneDao extends BaseDao<BookAppletScene> {
* @return
*/
BookAppletSceneDTO getBookAppletByBookId(Long bookId, Long channelId, Long adviserId);
String getAppletIdByBookGroupId(Long bookGroupId);
String getAppletIdBySceneId(Long sceneId);
}
......@@ -27,4 +27,6 @@ public interface ResourcePageCollectDao extends BaseDao<ResourcePageCollect>{
* * @param null
*/
Integer getUserIsNotNew(Long wechatUserId);
Integer getCollectStateByUser(Long wechatUserId, Long resourcePageId);
}
\ No newline at end of file
......@@ -125,4 +125,8 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
* * @param null
*/
void updateNavigationFormat(Long resourcePageId, Integer navigationColor, Integer navigationFormat, Integer navigationJumpType);
Long getBookIdByBookGroupId(Long bookGroupId);
Long getBookIdBySceneId(Long sceneId);
}
......@@ -56,4 +56,14 @@ public class BookAppletSceneDaoImpl extends BaseDaoImpl<BookAppletScene> impleme
map.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("getBookAppletByBookId"), map);
}
@Override
public String getAppletIdByBookGroupId(Long bookGroupId) {
return getSessionTemplate().selectOne(getStatement("getAppletIdByBookGroupId"), bookGroupId);
}
@Override
public String getAppletIdBySceneId(Long sceneId) {
return getSessionTemplate().selectOne(getStatement("getAppletIdBySceneId"), sceneId);
}
}
......@@ -31,4 +31,12 @@ public class ResourcePageCollectDaoImpl extends BaseDaoImpl<ResourcePageCollect>
public Integer getUserIsNotNew(Long wechatUserId) {
return getSessionTemplate().selectOne(getStatement("getUserIsNotNew"), wechatUserId);
}
@Override
public Integer getCollectStateByUser(Long wechatUserId, Long resourcePageId) {
Map<String, Object> map = new HashMap<>();
map.put("wechatUserId", wechatUserId);
map.put("resourcePageId", resourcePageId);
return getSessionTemplate().selectOne(getStatement("getCollectStateByUser"), map);
}
}
......@@ -166,4 +166,14 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
map.put("navigationJumpType", navigationJumpType);
getSessionTemplate().update(getStatement("updateNavigationFormat"), map);
}
@Override
public Long getBookIdByBookGroupId(Long bookGroupId) {
return getSessionTemplate().selectOne(getStatement("getBookIdByBookGroupId"), bookGroupId);
}
@Override
public Long getBookIdBySceneId(Long sceneId) {
return getSessionTemplate().selectOne(getStatement("getBookIdBySceneId"), sceneId);
}
}
......@@ -141,4 +141,22 @@
limit 1
</select>
<select id="getAppletIdByBookGroupId" parameterType="long" resultType="string">
SELECT
applet_id
FROM book_applet_scene
WHERE book_group_id=#{bookGroupId}
AND is_delete = 0
limit 1
</select>
<select id="getAppletIdBySceneId" parameterType="long" resultType="string">
SELECT
applet_id
FROM book_applet_scene
WHERE scene_id=#{sceneId}
AND is_delete = 0
limit 1
</select>
</mapper>
\ No newline at end of file
......@@ -71,4 +71,14 @@
and is_new = 0
</select>
<select id="getCollectStateByUser" parameterType="map" resultType="integer">
select
collect_state
from resource_page_collect
where resource_page_id = #{resourcePageId}
and wechat_user_id = #{wechatUserId}
and collect_state = 1
limit 1
</select>
</mapper>
\ No newline at end of file
......@@ -355,4 +355,20 @@
where id = #{id}
</select>
<select id="getBookIdByBookGroupId" parameterType="long" resultType="long" >
select
book_id
from resource_page
where book_group_id = #{bookGroupId}
limit 1
</select>
<select id="getBookIdBySceneId" parameterType="long" resultType="long">
select
book_id
from resource_page
where scene_id = #{sceneId}
limit 1
</select>
</mapper>
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