Commit aec0b13e by 郑勇

bug: [1029330] erp多个码对应rays一个码

parent d6a130d5
......@@ -184,6 +184,10 @@ public interface BookAdviserService {
@ApiOperation("erp获取二维码下面配置了企业微信的二维码")
ResponseEntity<ResponseDto<List<Long>>> getHasWxWorkCode(@RequestBody List<Long> sceneIds);
@PostMapping("getHasResourceCode")
@ApiOperation("erp获取配置了资源的Rays码")
ResponseEntity<ResponseDto<List<Long>>> getHasResourceCode(@RequestBody List<Long> sceneIds);
@GetMapping("getBookIdsByAgentId")
@ApiOperation("根据agentId获取书籍id")
void getBookIdsByAgentId(@RequestParam("agentId") Long agentId);
......
......@@ -44,6 +44,10 @@ public class BookGroupServeCountDTO extends BaseDto {
@ApiModelProperty("公众号sceneid/RAYS码bookgroupid")
private Long bookQrcodeId;
@ApiModelProperty("sceneId")
private Long sceneId;
@ApiModelProperty("sceneId数组")
private String sceneIdStr;
......
......@@ -379,6 +379,15 @@ public interface BookAdviserBiz {
List<Long> getHasWxWorkCode(List<Long> sceneIds);
/**
* erp获取rays自有码下面是否配置了资源
* @param sceneIds
* @return
*/
List<Long> getHasResourceCode4Erp(List<Long> sceneIds);
/**
* 根据agentId获取书籍id
* @param agentId
*/
......
......@@ -3103,7 +3103,8 @@ public class BookBizImpl implements BookBiz {
qrcodeSceneDtos = Lists.newArrayList();
}
// 获取所有的社群码
List<BookGroupDTO> bookGroupList = bookGroupDao.getDTOByBookIdsAdviserIdsChannelIds(Lists.newArrayList(bookId), Lists.newArrayList(adviserId), Lists.newArrayList(channelId));
//List<BookGroupDTO> bookGroupList = bookGroupDao.getDTOByBookIdsAdviserIdsChannelIds(Lists.newArrayList(bookId), Lists.newArrayList(adviserId), Lists.newArrayList(channelId));
List<BookGroupDTO> bookGroupList = bookGroupDao.getNotXiaoRui(Lists.newArrayList(bookId), Lists.newArrayList(adviserId), Lists.newArrayList(channelId));
if(CollectionUtils.isEmpty(bookGroupList)){
bookGroupList = Lists.newArrayList();
}
......
......@@ -385,6 +385,12 @@ public class BookAdviserFacadeImpl implements BookAdviserFacade {
return new ResponseDto<>(bookAdviserBiz.getHasWxWorkCode(sceneIds));
}
@ApiOperation("erp获取rays自有码下面是否配置了资源")
@PostMapping("getHasResourceCode4Erp")
public ResponseDto<?> getHasResourceCode4Erp(@RequestBody List<Long> sceneIds) {
return new ResponseDto<>(bookAdviserBiz.getHasResourceCode4Erp(sceneIds));
}
@PostMapping("getBooksByAgentToken")
public ResponseDto<List<Long>>getBooksByAgentToken(@RequestParam(value = "token") String token,@RequestParam(value = "index") int index,@RequestParam(value = "month" ,required = false) Integer month){
Long agentId = (Long)SessionUtil.getVlaue(token, SessionUtil.PARTY_ID);
......
......@@ -207,6 +207,12 @@ public class BookAdviserServiceImpl implements BookAdviserService {
}
@Override
@PostMapping("getHasResourceCode")
public ResponseEntity<ResponseDto<List<Long>>> getHasResourceCode(@RequestBody List<Long> sceneIds) {
return ResponseHandleUtil.toResponse(bookAdviserBiz.getHasResourceCode4Erp(sceneIds));
}
@Override
public void getBookIdsByAgentId(Long agentId) {
bookAdviserBiz.getBookIdsByAgentId(agentId);
}
......
......@@ -177,11 +177,12 @@ public class ChannelConsr {
}
}
public Map<String, QrcodeMessageDTO> mapResourceCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
public Map<String, QrcodeMessageDTO> mapResourceCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds,Integer codeType) {
MapResourceCountDTO mapResourceCountDTO = new MapResourceCountDTO();
mapResourceCountDTO.setAdviserIds(adviserIds);
mapResourceCountDTO.setBookIds(bookIds);
mapResourceCountDTO.setChannelIds(channelIds);
mapResourceCountDTO.setCodeType(codeType);
Map<String, QrcodeMessageDTO> mapQrcodeMessage = ResponseHandleUtil.parseMap(qrcodeSceneService.mapResourceCount(mapResourceCountDTO), String.class, QrcodeMessageDTO.class);
return mapQrcodeMessage;
}
......
......@@ -2,6 +2,7 @@ package com.pcloud.book.group.biz;
import com.pcloud.book.book.dto.RaysSceneCatalogDto;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageCourseDTO;
......@@ -329,4 +330,12 @@ public interface ResourcePageBiz {
List<String> mapCatalogBook(List<Long> bookIds, Long adviserId);
List<RaysSceneCatalogDto> listRaysSceneCatalogDto(List<Long> sceneIds);
/**
* rays码下面资源数量
* @param adviserIds
* @param bookIds
* @param channelIds
*/
Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds);
}
......@@ -46,6 +46,7 @@ import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.dao.ResourcePageToolDao;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageCourseDTO;
......@@ -97,6 +98,7 @@ import com.pcloud.message.common.enums.YesNoEnums;
import com.pcloud.resourcecenter.product.dto.ProductDto;
import com.pcloud.usercenter.party.adviser.dto.AdviserBaseInfoDto;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -1694,4 +1696,12 @@ public class ResourcePageBizImpl implements ResourcePageBiz {
return Optional.ofNullable(bookGroupDao.listRaysSceneCatalogDto(sceneIds)).orElse(new ArrayList<>());
}
@Override
public Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
if(CollectionUtils.isEmpty(adviserIds) || CollectionUtils.isEmpty(bookIds) || CollectionUtils.isEmpty(channelIds)){
return new HashMap<>();
}
return resourcePageDao.mapRaysCodeServeCount(adviserIds, bookIds, channelIds);
}
}
......@@ -15,6 +15,7 @@ import com.pcloud.channelcenter.qrcode.vo.BookQrcodeVO;
import com.pcloud.book.rightsSetting.dto.ServeIdTypeDTO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
......@@ -401,4 +402,6 @@ public interface BookGroupDao extends BaseDao<BookGroup> {
List<Long> mapCatalogBook(List<Long> bookIds, Long adviserId);
List<RaysSceneCatalogDto> listRaysSceneCatalogDto(List<Long> sceneIds);
List<BookGroupDTO> getNotXiaoRui(List<Long> bookIds, List<Long> adviserIds, List<Long> channelIds);
}
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.ResourcePage;
import com.pcloud.common.core.dao.BaseDao;
......@@ -105,4 +106,6 @@ public interface ResourcePageDao extends BaseDao<ResourcePage>{
* * @param null
*/
Boolean isOpenRaysBook(Long bookId, Long channelId, Long adviserId);
Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds);
}
\ No newline at end of file
package com.pcloud.book.group.dao;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.dto.BookGroupServeDTO;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageUrlDTO;
......@@ -9,6 +10,7 @@ import com.pcloud.book.group.vo.ResourcePageItemVO;
import com.pcloud.common.core.dao.BaseDao;
import java.util.List;
import java.util.Map;
/**
* 自有码H5页面栏目资源详情(ResourcePageItem)表数据库访问层
......@@ -90,4 +92,18 @@ public interface ResourcePageItemDao extends BaseDao<ResourcePageItem>{
List<ResourcePageUrlDTO> getServeUrl4Update(List<Long> sceneIdList);
void batchUpdateServeUrlById(List<ResourcePageUrlDTO> list);
/**
* 算码下面的资源
* @param ruiList
* @return
*/
Map<Long, BookGroupServeCountDTO> mapQrServeCount(List<Long> ruiList);
/**
* 过滤有资源的rays码
* @param sceneIds
* @return
*/
List<Long> getHasResourceCode4Erp(List<Long> sceneIds);
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import com.pcloud.common.utils.ListForInSQL;
import com.pcloud.common.utils.ListUtils;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -569,4 +570,13 @@ public class BookGroupDaoImpl extends BaseDaoImpl<BookGroup> implements BookGrou
public List<RaysSceneCatalogDto> listRaysSceneCatalogDto(List<Long> sceneIds) {
return getSessionTemplate().selectList(getStatement("listRaysSceneCatalogDto"), MapUtil.of("sceneIds", sceneIds));
}
@Override
public List<BookGroupDTO> getNotXiaoRui(List<Long> bookIds, List<Long> adviserIds, List<Long> channelIds) {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("bookIds",bookIds);
paramMap.put("adviserIds",adviserIds);
paramMap.put("channelIds",channelIds);
return super.getSqlSession().selectList(getStatement("getNotXiaoRui"),paramMap);
}
}
......@@ -2,8 +2,10 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.ResourcePageDao;
import com.pcloud.book.group.dto.AddBookGroupServeDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.ResourcePage;
import com.pcloud.common.core.dao.BaseDaoImpl;
import com.pcloud.common.utils.ListUtils;
import org.springframework.stereotype.Component;
......@@ -97,4 +99,29 @@ public class ResourcePageDaoImpl extends BaseDaoImpl<ResourcePage> implements Re
map.put("adviserId", adviserId);
return getSessionTemplate().selectOne(getStatement("isOpenRaysBook"), map);
}
@Override
public Map<String, BookGroupServeCountDTO> mapRaysCodeServeCount(List<Long> adviserIds, List<Long> bookIds, List<Long> channelIds) {
if (bookIds != null && bookIds.size() > 500) {
Map<String, BookGroupServeCountDTO>resultMap = new HashMap<>();
List<List<Long>> lists = ListUtils.groupList(bookIds);
for (List<Long> list : lists) {
Map<String, Object> map = new HashMap<>();
map.put("adviserIds", adviserIds);
map.put("bookIds", list);
map.put("channelIds", channelIds);
Map<String, BookGroupServeCountDTO> objectObjectMap = getSessionTemplate().selectMap(getStatement("mapRaysCodeServeCount"), map, "bookChannelAdviserId");
if(objectObjectMap!=null){
resultMap.putAll(objectObjectMap);
}
}
return resultMap;
} else {
Map<String, Object> map = new HashMap<>();
map.put("adviserIds", adviserIds);
map.put("bookIds", bookIds);
map.put("channelIds", channelIds);
return getSessionTemplate().selectMap(getStatement("mapRaysCodeServeCount"), map, "bookChannelAdviserId");
}
}
}
......@@ -3,6 +3,7 @@ package com.pcloud.book.group.dao.impl;
import com.pcloud.book.group.dao.ResourcePageItemDao;
import com.pcloud.book.group.dto.BookServeDTO;
import com.pcloud.book.group.dto.ResourcePageUrlDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.entity.BookGroupServe;
import com.pcloud.book.group.entity.ResourcePageItem;
import com.pcloud.book.group.vo.ResourcePageItemVO;
......@@ -93,4 +94,18 @@ public class ResourcePageItemDaoImpl extends BaseDaoImpl<ResourcePageItem> imple
public void batchUpdateServeUrlById(List<ResourcePageUrlDTO> list) {
getSessionTemplate().update(getStatement("batchUpdateServeUrlById"), list);
}
@Override
public Map<Long, BookGroupServeCountDTO> mapQrServeCount(List<Long> ruiList) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("sceneIds", ruiList);
return getSessionTemplate().selectMap(getStatement("mapQrServeCount"), paramMap, "sceneId");
}
@Override
public List<Long> getHasResourceCode4Erp(List<Long> sceneIds) {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("sceneIds", sceneIds);
return getSessionTemplate().selectList(getStatement("getHasResourceCode4Erp"), paramMap);
}
}
......@@ -153,6 +153,7 @@
and book_id = #{bookId,jdbcType=BIGINT}
and channel_id = #{channelId,jdbcType=BIGINT}
and create_user = #{adviserId,jdbcType=BIGINT}
and join_group_type != 4
</select>
<select id="getDTOByBookIdsAnsAdviserIds" resultMap="BookGroupDTO" parameterType="map">
......@@ -1416,4 +1417,23 @@
HAVING
count( b.id ) =1
</select>
<select id="getNotXiaoRui" resultMap="BookGroupDTO" parameterType="map">
select
<include refid="Base_Column_List"/>
from book_group
where is_delete = 0 AND book_id in
<foreach collection="bookIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and create_user in
<foreach collection="adviserIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and channel_id in
<foreach collection="channelIds" open="(" close=")" item="item" separator=",">
${item}
</foreach>
and join_group_type!=4
</select>
</mapper>
......@@ -235,7 +235,7 @@
<foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")">
${adviserId}
</foreach>
AND bg.join_group_type IN (2,3,4)
AND bg.join_group_type IN (2,3)
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
......@@ -255,7 +255,7 @@
<foreach collection="bookGroupIds" item="bookGroupId" separator="," open="(" close=")">
${bookGroupId}
</foreach>
AND bg.join_group_type IN (2,3,4)
AND bg.join_group_type IN (2,3)
GROUP BY bg.id
</select>
......
......@@ -228,4 +228,27 @@
AND channel_id = #{channelId}
AND open_rays = 1
</select>
<select id="mapRaysCodeServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId,ifnull(COUNT(DISTINCT bk.id),0) serveCount,
bg.book_id bookId,bg.create_user adviserId,bg.channel_id channelId
FROM
resource_page bg
LEFT JOIN resource_page_item bk ON bg.id=bk.resource_page_id
WHERE
bg.book_id IN
<foreach collection="bookIds" item="bookId" separator="," open="(" close=")">
${bookId}
</foreach>
AND bg.channel_id IN
<foreach collection="channelIds" item="channelId" separator="," open="(" close=")">
${channelId}
</foreach>
AND bg.create_user IN
<foreach collection="adviserIds" item="adviserId" separator="," open="(" close=")">
${adviserId}
</foreach>
GROUP BY bg.book_id,bg.create_user,bg.channel_id
</select>
</mapper>
\ No newline at end of file
......@@ -257,4 +257,34 @@
${item.id}
</foreach>
</update>
<select id="mapQrServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT
p.book_group_id bookQrcodeId,
p.scene_id sceneId,
ifnull(count(i.id),0) serveCount
FROM
resource_page p
LEFT JOIN resource_page_item i ON i.resource_page_id = p.id
WHERE
p.scene_id in
<foreach collection="sceneIds" index="index" separator="," open="(" close=")" item="item">
#{item}
</foreach>
group by p.scene_id
</select>
<select id="getHasResourceCode4Erp" parameterType="map" resultType="Long">
SELECT
p.scene_id
FROM
resource_page p
LEFT JOIN resource_page_item i ON i.resource_page_id = p.id
WHERE
p.scene_id in
<foreach collection="sceneIds" index="index" separator="," open="(" close=")" item="item">
#{item}
</foreach>
group by p.scene_id having count(i.id)>0
</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