Commit 91eabff9 by 田超

Merge branch 'feature/1003949' into 'master'

feat: [1003949] 优化测试书在小程序搜索分类栏的显示

See merge request rays/pcloud-book!1096
parents 219f8f7f 6f18540f
package com.pcloud.book.book.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ErpBookApprovalDTO {
private Long bookId;
private Long adviserId;
private Long channelId;
@ApiModelProperty("是否已立项")
private Integer isApproval;
}
......@@ -7,6 +7,7 @@ import com.alibaba.fastjson.TypeReference;
import com.pcloud.book.base.exception.BookBizException;
import com.pcloud.book.book.dto.CreateBookResultVO;
import com.pcloud.book.book.dto.ERPPublishNumDTO;
import com.pcloud.book.book.dto.ErpBookApprovalDTO;
import com.pcloud.book.book.dto.ErpBookInfoDTO;
import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException;
......@@ -237,4 +238,34 @@ public class ErpConsr {
throw new BookBizException(BookBizException.INVOKE_CONTENT_ERROR, "模糊查询erp图书ID失败!");
}
}
@ParamLog("查询erp图书是否立项")
public Map<String, ErpBookApprovalDTO> getIsApproval(List<Long> adviserIds, List<Long> channelIds, List<Long> bookIds) {
if (ListUtils.isEmpty(adviserIds) || ListUtils.isEmpty(channelIds) || ListUtils.isEmpty(bookIds)){
return new HashMap<>();
}
adviserIds.remove(0L);
channelIds.remove(0L);
bookIds.remove(0L);
Map<String, List<Long>> bookAdviserChannelIdMap = new HashMap<>();
bookAdviserChannelIdMap.put("adviserIds", adviserIds);
bookAdviserChannelIdMap.put("channelIds", channelIds);
bookAdviserChannelIdMap.put("bookIds", bookIds);
Map<String, ErpBookApprovalDTO> resultMap = null;
Map<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json");
try {
HttpResponse response = HttpUtils.doPost(domain, "/erp/project4Third/getIsApproval", "POST", headers, new HashMap<>(), JSONObject.toJSONString(bookAdviserChannelIdMap));
String entityString = EntityUtils.toString(response.getEntity());
JSONObject jsonObject = JSONObject.parseObject(entityString);
if (jsonObject.getInteger("errCode") != 0) {
LOGGER.error("查询erp图书是否立项失败 [erpConsr.getIsApproval]:" + jsonObject.getString("message"));
}
return JSONObject.parseObject(jsonObject.getString("data"), new TypeReference<Map<String, ErpBookApprovalDTO>>(){});
} catch (Exception e) {
LOGGER.error("查询erp图书是否立项失败 [erpConsr.getIsApproval]:" + e.getMessage(), e);
}
return new HashMap<>();
}
}
......@@ -4,8 +4,10 @@ import com.pcloud.analysisengine.browse.dto.BrowseCacheRecordDto;
import com.pcloud.book.applet.biz.AppletUserBookcaseBiz;
import com.pcloud.book.book.constant.BookConstant;
import com.pcloud.book.book.dao.BookDao;
import com.pcloud.book.book.dto.ErpBookApprovalDTO;
import com.pcloud.book.consumer.analysisengine.BrowseRecordConsr;
import com.pcloud.book.consumer.channel.QrcodeSceneConsr;
import com.pcloud.book.consumer.erp.ErpConsr;
import com.pcloud.book.consumer.trade.TradeConsr;
import com.pcloud.book.es.biz.ESBookAndAdviserBiz;
import com.pcloud.book.es.entity.ESBookAndAdviser;
......@@ -71,6 +73,8 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
private BrowseRecordConsr browseRecordConsr;
@Autowired
private TradeConsr tradeConsr;
@Autowired
private ErpConsr erpConsr;
@ParamLog("导入全部book和bookAdviser")
@Transactional(rollbackFor = Exception.class)
......@@ -110,6 +114,10 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
Set<Long> searchBookIds = new HashSet<>();
Set<Long> channelIds = new HashSet<>();
Set<Long> adviserIds = new HashSet<>();
Set<Long> sourceBookIds = new HashSet<>();
Set<Long> sourceChannelIds = new HashSet<>();
Set<Long> sourceAdviserIds = new HashSet<>();
List<BookIncomeQueryVo> bookIncomeQueryVos = new ArrayList<BookIncomeQueryVo>();
for (ESBookAndAdviser esBookAndAdviser : list){
if (esBookAndAdviser.getIsFundSupport()==1){//统计基金书数据
......@@ -122,11 +130,16 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
bookIncomeQueryVo.setAdviserId(Long.valueOf(esBookAndAdviser.getAdviserId()));
bookIncomeQueryVos.add(bookIncomeQueryVo);
}
sourceBookIds.add(Long.valueOf(esBookAndAdviser.getBookId()));
sourceAdviserIds.add(Long.valueOf(esBookAndAdviser.getAdviserId()));
sourceChannelIds.add(Long.valueOf(esBookAndAdviser.getChannelId()));
}
//书刊扫码量浏览量
Map<String, BrowseCacheRecordDto> bookSvUvPvMap = browseRecordConsr.getBookSvUvPv(new ArrayList<>(adviserIds),new ArrayList<>(channelIds),new ArrayList<>(searchBookIds));
// 获取书刊累计收益(销售额)
Map<String, IncomeBackDto> bookIncomeMap = tradeConsr.getBookIncome(bookIncomeQueryVos, null);
// 获取书刊是否立项
Map<String, ErpBookApprovalDTO> erpBookApprovalMap = erpConsr.getIsApproval(new ArrayList<>(sourceAdviserIds), new ArrayList<>(sourceChannelIds), new ArrayList<>(sourceBookIds));
for (ESBookAndAdviser bookAndAdviser : list){
String key = bookAndAdviser.getBookId() + "-" + bookAndAdviser.getAdviserId() + "-" + bookAndAdviser.getChannelId();
Integer resourceCount=0;
......@@ -158,6 +171,9 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
fundBookValue = income.multiply(new BigDecimal(10)).add(new BigDecimal(scanCount*3)).add(new BigDecimal(browseCounts));
}
bookAndAdviser.setFundBookValue(fundBookValue == null?BigDecimal.ZERO:fundBookValue);
if(!MapUtils.isEmpty(erpBookApprovalMap) && erpBookApprovalMap.containsKey(key)){
bookAndAdviser.setIsApproval(erpBookApprovalMap.get(key).getIsApproval());
}
}
}
......@@ -300,7 +316,7 @@ public class ESBookAndAdviserBizImpl implements ESBookAndAdviserBiz {
boolQueryBuilder.must(must1);
}
// 排序:因为涉及分词,故而_score固定放在第一位
Sort sort = new Sort(Sort.Direction.DESC, "_score", "isFundSupport", "fundBookValue", "resourceCount", "isAdviserBook", "lastModifiedDate", "bookId");
Sort sort = new Sort(Sort.Direction.DESC, "_score", "isApproval", "isFundSupport", "fundBookValue", "resourceCount", "isAdviserBook", "lastModifiedDate", "bookId");
PageRequest pageRequest = new PageRequest(currentPage, numPerPage, sort);
Page<ESBookAndAdviser> search = bookAndAdviserRepository.search(boolQueryBuilder, pageRequest);
......
......@@ -157,5 +157,8 @@ public class ESBookAndAdviser {
* 基金书访问量公式(GMV*10+扫码*3+浏览量)
*/
private BigDecimal fundBookValue;
/**
* 是否已立项
*/
private Integer isApproval;
}
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