Commit 911f9a8c by 郑永强

feat: [1003407] ERP关联书刊(小睿书刊),若书刊配置了小睿书刊权益,则资源数修改为权益数

parent 3f214798
...@@ -30,4 +30,10 @@ public class BookGroupServeCountDTO extends BaseDto { ...@@ -30,4 +30,10 @@ public class BookGroupServeCountDTO extends BaseDto {
@ApiModelProperty("二维码数量") @ApiModelProperty("二维码数量")
private Integer qrcodeCount; private Integer qrcodeCount;
@ApiModelProperty("群类型")
private Integer joinGroupType;
@ApiModelProperty("权益数量")
private Integer rightsCount;
} }
...@@ -22,6 +22,7 @@ import com.pcloud.book.group.dto.BookGroupDTO; ...@@ -22,6 +22,7 @@ import com.pcloud.book.group.dto.BookGroupDTO;
import com.pcloud.book.group.dto.BookGroupServeCountDTO; import com.pcloud.book.group.dto.BookGroupServeCountDTO;
import com.pcloud.book.group.enums.JoinGroupTypeEnum; import com.pcloud.book.group.enums.JoinGroupTypeEnum;
import com.pcloud.book.rightsSetting.biz.RightsSettingBiz; import com.pcloud.book.rightsSetting.biz.RightsSettingBiz;
import com.pcloud.book.rightsSetting.dao.RightsSettingDAO;
import com.pcloud.book.rightsSetting.dto.RightsSettingDto; import com.pcloud.book.rightsSetting.dto.RightsSettingDto;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz; import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
...@@ -133,6 +134,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -133,6 +134,8 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
private BookGroupDao bookGroupDao; private BookGroupDao bookGroupDao;
@Autowired @Autowired
private RightsSettingBiz rightsSettingBiz; private RightsSettingBiz rightsSettingBiz;
@Autowired
private RightsSettingDAO rightsSettingDAO;
@Autowired @Autowired
private ESBookAndAdviserBiz esBookAndAdviserBiz; private ESBookAndAdviserBiz esBookAndAdviserBiz;
...@@ -942,14 +945,29 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -942,14 +945,29 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
if(JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){ if(JoinGroupTypeEnum.ROBOT.getCode().equals(bookGroupDTO.getJoinGroupType())){
mapBookGroupRobotServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId), JoinGroupTypeEnum.ROBOT.getCode()); mapBookGroupRobotServeCount = bookGroupBiz.mapBookGroupQrcodeServeCount(Lists.newArrayList(adviserId),Lists.newArrayList(bookId),Lists.newArrayList(channelId), JoinGroupTypeEnum.ROBOT.getCode());
} }
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupDTO.getJoinGroupType())){
// 小睿权益数量
List<RightsSettingDto> rightsSettingDtos = rightsSettingDAO.listByBookId(bookId);
if(!CollectionUtils.isEmpty(rightsSettingDtos) && mapBookGroupServeCount != null && !mapBookGroupServeCount.isEmpty()){
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.values().stream().findFirst().get();
if(bookGroupServeCountDTO!=null){
bookGroupServeCountDTO.setRightsCount(rightsSettingDtos.get(0).getCount());
}
}
}
} }
QrCodeVO qrCodeVO = new QrCodeVO(); QrCodeVO qrCodeVO = new QrCodeVO();
qrCodeVO.setQrCodeName(bookGroupDTO.getGroupQrcodeName()); qrCodeVO.setQrCodeName(bookGroupDTO.getGroupQrcodeName());
qrCodeVO.setQrCodeUrl(bookGroupDTO.getGroupQrcodeUrl()); qrCodeVO.setQrCodeUrl(bookGroupDTO.getGroupQrcodeUrl());
qrCodeVO.setServeCount(0); qrCodeVO.setServeCount(0);
qrCodeVO.setJoinGroupType(bookGroupDTO.getJoinGroupType());
if(mapBookGroupServeCount!=null && !mapBookGroupServeCount.isEmpty()) { if(mapBookGroupServeCount!=null && !mapBookGroupServeCount.isEmpty()) {
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get("" + bookId + "_" + channelId + "_" + adviserId); BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupServeCount.get("" + bookId + "_" + channelId + "_" + adviserId);
qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount()); qrCodeVO.setServeCount(bookGroupServeCountDTO.getServeCount());
// 如果是小睿码,则显示权益数
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())){
qrCodeVO.setServeCount(null == bookGroupServeCountDTO.getRightsCount() ? 0 : bookGroupServeCountDTO.getRightsCount());
}
} }
if(mapBookGroupRobotServeCount!=null && !mapBookGroupRobotServeCount.isEmpty()){ if(mapBookGroupRobotServeCount!=null && !mapBookGroupRobotServeCount.isEmpty()){
BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupRobotServeCount.get("" + bookId + "_" + channelId + "_" + adviserId); BookGroupServeCountDTO bookGroupServeCountDTO = mapBookGroupRobotServeCount.get("" + bookId + "_" + channelId + "_" + adviserId);
...@@ -1007,6 +1025,21 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -1007,6 +1025,21 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
bookChannelAdviserIds.addAll(mapBookGroupRobotServeCount.keySet().stream().collect(Collectors.toList())); bookChannelAdviserIds.addAll(mapBookGroupRobotServeCount.keySet().stream().collect(Collectors.toList()));
bookChannelAdviserIds = bookChannelAdviserIds.stream().distinct().collect(Collectors.toList()); bookChannelAdviserIds = bookChannelAdviserIds.stream().distinct().collect(Collectors.toList());
// 处理权益数
Map<Long, RightsSettingDto> rightsMap = rightsSettingDAO.listByBookIds(bookIds);
if(rightsMap!=null && !rightsMap.isEmpty()){
for (BookGroupServeCountDTO bookGroupServeCountDTO : mapBookGroupServeCount.values()) {
if(!JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())){
continue;
}
// 如果是小睿码,则显示权益数
RightsSettingDto rightsSettingDto = rightsMap.get(bookGroupServeCountDTO.getBookId());
if(rightsSettingDto!=null){
bookGroupServeCountDTO.setRightsCount(rightsSettingDto.getCount());
}
}
}
BookResourceStatisticsDTO bookResourceStatisticsDTO; BookResourceStatisticsDTO bookResourceStatisticsDTO;
for (String bookChannelAdviserId : bookChannelAdviserIds) { for (String bookChannelAdviserId : bookChannelAdviserIds) {
// mapBookGroupServeCount 包含了(客服机器人、1v1、小睿) // mapBookGroupServeCount 包含了(客服机器人、1v1、小睿)
...@@ -1034,7 +1067,12 @@ public class BookAdviserBizImpl implements BookAdviserBiz { ...@@ -1034,7 +1067,12 @@ public class BookAdviserBizImpl implements BookAdviserBiz {
bookResourceStatisticsDTO.setQrcodeCount(0); bookResourceStatisticsDTO.setQrcodeCount(0);
bookResourceStatisticsDTO.setServeCount(0); bookResourceStatisticsDTO.setServeCount(0);
} }
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + bookGroupServeCountDTO.getServeCount()); Integer serveCount = bookGroupServeCountDTO.getServeCount();
// 如果是小睿码,则显示权益数
if(JoinGroupTypeEnum.XIAORUI.getCode().equals(bookGroupServeCountDTO.getJoinGroupType())){
serveCount = null == bookGroupServeCountDTO.getRightsCount() ? 0 : bookGroupServeCountDTO.getRightsCount();
}
bookResourceStatisticsDTO.setServeCount(bookResourceStatisticsDTO.getServeCount() + serveCount);
if(!added){ if(!added){
bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + bookGroupServeCountDTO.getQrcodeCount()); bookResourceStatisticsDTO.setQrcodeCount(bookResourceStatisticsDTO.getQrcodeCount() + bookGroupServeCountDTO.getQrcodeCount());
added = true; added = true;
......
...@@ -10,4 +10,6 @@ public class QrCodeVO { ...@@ -10,4 +10,6 @@ public class QrCodeVO {
private String qrCodeUrl; private String qrCodeUrl;
private Integer serveCount; private Integer serveCount;
private Integer joinGroupType;
} }
...@@ -26,4 +26,6 @@ public interface RightsSettingDAO extends BaseDao<RightsSetting> { ...@@ -26,4 +26,6 @@ public interface RightsSettingDAO extends BaseDao<RightsSetting> {
List<RightsSettingDto> listByBookId(Long bookId); List<RightsSettingDto> listByBookId(Long bookId);
void batchUpdateShowState(RightsSettingShowStateDTO rightsSettingShowStateDTO); void batchUpdateShowState(RightsSettingShowStateDTO rightsSettingShowStateDTO);
Map<Long, RightsSettingDto> listByBookIds(List<Long> bookIds);
} }
...@@ -64,4 +64,9 @@ public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implement ...@@ -64,4 +64,9 @@ public class RightsSettingDAOImpl extends BaseDaoImpl<RightsSetting> implement
public void batchUpdateShowState(RightsSettingShowStateDTO rightsSettingShowStateDTO) { public void batchUpdateShowState(RightsSettingShowStateDTO rightsSettingShowStateDTO) {
getSessionTemplate().update(getStatement("batchUpdateShowState"), rightsSettingShowStateDTO); getSessionTemplate().update(getStatement("batchUpdateShowState"), rightsSettingShowStateDTO);
} }
@Override
public Map<Long, RightsSettingDto> listByBookIds(List<Long> bookIds) {
return getSessionTemplate().selectMap(getStatement("listByBookIds"), bookIds, "bookId");
}
} }
...@@ -214,7 +214,8 @@ ...@@ -214,7 +214,8 @@
<select id="mapBookGroupServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO"> <select id="mapBookGroupServeCount" parameterType="map" resultType="com.pcloud.book.group.dto.BookGroupServeCountDTO">
SELECT SELECT
CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId, COUNT(bgs.id) serveCount, CONCAT(bg.book_id,'_',bg.channel_id,'_',bg.create_user) bookChannelAdviserId, COUNT(bgs.id) serveCount,
bg.book_id bookId, bg.create_user adviserId, bg.channel_id channelId,COUNT(DISTINCT bg.group_qrcode_url) qrcodeCount bg.book_id bookId, bg.create_user adviserId, bg.channel_id channelId,COUNT(DISTINCT bg.group_qrcode_url) qrcodeCount,
bg.join_group_type joinGroupType
FROM `book_group` bg LEFT JOIN book_group_serve bgs ON bg.id = bgs.book_group_id FROM `book_group` bg LEFT JOIN book_group_serve bgs ON bg.id = bgs.book_group_id
WHERE WHERE
bg.is_delete=0 bg.is_delete=0
......
...@@ -71,6 +71,12 @@ ...@@ -71,6 +71,12 @@
,r.online_course_open,r.learning_tool_open,r.draw_open,r.read_type_title,r.vol_label_id,r.ver_label_id, r.show_state ,r.online_course_open,r.learning_tool_open,r.draw_open,r.read_type_title,r.vol_label_id,r.ver_label_id, r.show_state
</sql> </sql>
<sql id="Base_Column_List_1" >
r.id, r.introduce, r.detail, r.count, r.first_classify, r.second_classify, r.grade_label_id, r.subject_label_id,
r.create_time, r.update_time, r.enable_group_service, r.rights_setting_type, b.book_id
,r.online_course_open,r.learning_tool_open,r.draw_open,r.read_type_title,r.vol_label_id,r.ver_label_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" > <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
...@@ -301,6 +307,19 @@ ...@@ -301,6 +307,19 @@
and rights_setting_type = 2 and rights_setting_type = 2
</select> </select>
<select id="listByBookIds" resultMap="DtoResultMap">
select
<include refid="Base_Column_List_1"/>
from
rights_setting r
left join rights_setting_book_relation b on r.id = b.rights_setting_id
WHERE b.book_id IN
<foreach collection="list" item="item" separator="," open="(" close=")">
${item}
</foreach>
and rights_setting_type = 2
</select>
<update id="batchUpdateShowState" parameterType="com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO"> <update id="batchUpdateShowState" parameterType="com.pcloud.book.rightsSetting.dto.RightsSettingShowStateDTO">
UPDATE UPDATE
rights_setting rights_setting
...@@ -313,4 +332,4 @@ ...@@ -313,4 +332,4 @@
</foreach> </foreach>
</update> </update>
</mapper> </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