Commit 1587cafe by 田超

Merge branch 'feature/1004889' into 'master'

feat: [1004889] 小蓝书-关注公众号加付费

See merge request rays/pcloud-book!1339
parents 04c6a23a dd13f423
......@@ -279,4 +279,18 @@ public class AppConsr {
return new HashMap<>();
}
}
@ParamLog("查应用关联的公众号工具的付费公众号")
public Map<Long, Long> getPayOfficialAccountsToolByAppIds(List<Long> appIds) {
if (ListUtils.isEmpty(appIds)) {
return new HashMap<>();
}
try {
return ResponseHandleUtil.parseMapResponse(appService.getPayOfficialAccountsToolByAppIds(appIds), Long.class, Long.class);
} catch (Exception e) {
LOGGER.error("调用appService.getPayOfficialAccountsToolByAppIds失败"+e.getMessage(), e);
}
return new HashMap<>();
}
}
......@@ -23,6 +23,7 @@ import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumReqDTO;
import com.pcloud.channelcenter.wechat.dto.AdviserBookResourceNumRespDTO;
import com.pcloud.channelcenter.wechat.dto.BookServeParamVO;
import com.pcloud.channelcenter.wechat.dto.ListIsInBookParam;
import com.pcloud.channelcenter.wechat.entity.AccountSetting;
import com.pcloud.channelcenter.wechat.service.AccountSettingService;
import com.pcloud.channelcenter.wechat.service.MessageService;
import com.pcloud.channelcenter.wechat.vo.BookServeVO;
......@@ -609,4 +610,16 @@ public class QrcodeSceneConsr {
}
return qrcodeVO;
}
public AccountSetting getAppInfo(Long accountSettingId) {
AccountSetting accountSetting = new AccountSetting();
try {
accountSetting = ResponseHandleUtil.parseResponse(accountSettingService.getAppInfo(accountSettingId), AccountSetting.class);
} catch (Exception e) {
LOGGER.error("调用ccountSettingService.getAppInfo失败"+e.getMessage(), e);
}
return accountSetting;
}
}
......@@ -344,4 +344,12 @@ public interface ResourcePageBiz {
* @return
*/
List<ResourcePageVO> getAllBook4OpenFood();
/**
* 是否配置有使用付费公众号工具的应用
* @author:zhuyajie
* @date:2021/6/10 17:21
* * @param null
*/
Map<String, Object> hasOfficialAccountsTool(Long resourcePageId);
}
......@@ -800,7 +800,13 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
Map<Long, AppDto> appDtoMap = appConsr.mapBaseByIds(appIds);
Map<Long, ProductDto> productDtoMap = productConsr.getProBasesByIds(productIds);
Map<Long, AccountSettingDto> accountSettingDtoMap = new HashMap<>();
Map<Long, AccountSettingDto> channelAccountSettingDtoMap = new HashMap<>();
Map<Long, AccountSetting> accountSettingMap = new HashMap<>();
//应用配置公众号工具
Map<Long, Long> appOfficialAccountToolMap = new HashMap<>();
if (isWechat) {
appOfficialAccountToolMap = appConsr.getPayOfficialAccountsToolByAppIds(appIds);
}
for (ResourcePageItemVO itemVO : itemVOS) {
Long serveId = itemVO.getServeId();
String serveType = itemVO.getServeType();
......@@ -839,15 +845,41 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
itemVO.setChannelId(channelId);
if (isWechat) {
//客户端处理链接
setResourceLink4Wechat(itemVO, channelAccountSettingDtoMap, appOfficialAccountToolMap, accountSettingMap);
}
}
}
/**
* 客户端处理链接
* @author:zhuyajie
* @date:2021/6/10 11:20
* * @param null
*/
private void setResourceLink4Wechat(ResourcePageItemVO itemVO, Map<Long, AccountSettingDto> channelAccountSettingDtoMap,
Map<Long, Long> appOfficialAccountToolMap, Map<Long, AccountSetting> accountSettingMap) {
if (itemVO.getLinkUrl().startsWith("http")) {
itemVO.setResultUrl(itemVO.getLinkUrl());
continue;
return;
}
AccountSettingDto accountSettingDto = accountSettingDtoMap.get(channelId);
AccountSettingDto accountSettingDto = new AccountSettingDto();
//有应用配了付费公众号工具,取公众号工具的公众号域名, 没有就根据渠道id取
if (!MapUtils.isEmpty(appOfficialAccountToolMap) && appOfficialAccountToolMap.containsKey(itemVO.getServeId())) {
Long accountSettingId = appOfficialAccountToolMap.get(itemVO.getServeId());
AccountSetting accountSetting = accountSettingMap.get(accountSettingId);
if (null == accountSetting) {
accountSetting = qrcodeSceneConsr.getAppInfo(accountSettingId);
accountSettingMap.put(accountSettingId, accountSetting);
}
BeanUtils.copyProperties(accountSetting, accountSettingDto);
} else {
Long channelId = itemVO.getChannelId();
accountSettingDto = channelAccountSettingDtoMap.get(channelId);
if (accountSettingDto == null) {
accountSettingDto = qrcodeSceneConsr.getWechatInfo(channelId);
accountSettingDtoMap.put(channelId, accountSettingDto);
channelAccountSettingDtoMap.put(channelId, accountSettingDto);
}
}
if (null == accountSettingDto) {
throw new BookBizException(BookBizException.ERROR, itemVO.getServeName() + "未设置公众号");
......@@ -855,8 +887,7 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
String resultLinkUrl = SendWeixinRequestTools.splitUrl(accountSettingDto, itemVO.getLinkUrl());
itemVO.setResultUrl(resultLinkUrl);
}
}
}
private Long getChannelIdFromUrl(String url) {
Long channelId = null;
......@@ -1755,4 +1786,19 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
}
return resourcePageList;
}
@Override
public Map<String, Object> hasOfficialAccountsTool(Long resourcePageId) {
//是否有应用配了付费公众号工具
List<Long> appIds = resourcePageItemDao.getAppIdsByPageId(resourcePageId);
Boolean hasOfficialAccountsTool = false;
Map<Long, Long> map = appConsr.getPayOfficialAccountsToolByAppIds(appIds);
if (!MapUtils.isEmpty(map)) {
hasOfficialAccountsTool = true;
}
Map<String, Object> result = new HashMap<>();
result.put("hasOfficialAccountsTool", hasOfficialAccountsTool);
return result;
}
}
......@@ -106,4 +106,12 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{
* @return
*/
List<Long> getHasResourceCode4Erp(List<Long> sceneIds);
/**
* 查码下配置的应用id
* @author:zhuyajie
* @date:2021/6/10 11:13
* * @param null
*/
List<Long> getAppIdsByPageId(Long resourcePageId);
}
\ No newline at end of file
......@@ -108,4 +108,9 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple
paramMap.put("sceneIds", sceneIds);
return getSessionTemplate().selectList(getStatement("getHasResourceCode4Erp"), paramMap);
}
@Override
public List<Long> getAppIdsByPageId(Long resourcePageId) {
return getSessionTemplate().selectList(getStatement("getAppIdsByPageId"), resourcePageId);
}
}
......@@ -238,4 +238,11 @@ public class ResourcePageFacade {
public ResponseDto<List<ResourcePageVO>> getAllBook4OpenFood(){
return new ResponseDto<>(resourcePageBiz.getAllBook4OpenFood());
}
@ApiOperation("是否配置有使用付费公众号工具的应用")
@GetMapping("hasOfficialAccountsTool")
public ResponseDto<?> hasOfficialAccountsTool(@CookieValue("userInfo") String userInfo, @RequestParam("resourcePageId") Long resourcePageId) {
Cookie.getId(userInfo,Cookie._WECHAT_USER_ID);
return new ResponseDto<>(resourcePageBiz.hasOfficialAccountsTool(resourcePageId));
}
}
......@@ -287,4 +287,14 @@
</foreach>
group by p.scene_id having count(i.id)>0
</select>
<select id="getAppIdsByPageId" parameterType="long" resultType="long">
SELECT DISTINCT
serve_id
FROM
resource_page_item
WHERE
resource_page_id = #{resourcePageId}
AND serve_type = "APP"
</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