Commit 64ea9f67 by 王祖波

销售线索列表返回多商品页面信息

parent 27bfb90a
package com.gic.haoban.manage.api.dto.content;
import com.gic.haoban.manage.api.enums.content.InteractRecordExtendInfoDTO;
import java.io.Serializable;
import java.util.Date;
......@@ -100,6 +102,11 @@ public class PotentialCustomerDTO implements Serializable {
*/
private Integer durationTime;
/**
* 扩展信息
*/
private InteractRecordExtendInfoDTO extendInfo;
public Long getPotentialCustomerId() {
return potentialCustomerId;
}
......@@ -235,4 +242,12 @@ public class PotentialCustomerDTO implements Serializable {
public void setMemberNickName(String memberNickName) {
this.memberNickName = memberNickName;
}
public InteractRecordExtendInfoDTO getExtendInfo() {
return extendInfo;
}
public void setExtendInfo(InteractRecordExtendInfoDTO extendInfo) {
this.extendInfo = extendInfo;
}
}
package com.gic.haoban.manage.service.service.content.adaptor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.enterprise.api.dto.page.EnterpriseWxaLinkDTO;
import com.gic.enterprise.api.service.EnterpriseWxaLinkService;
import com.gic.haoban.manage.api.enums.content.MaterialInteractRecordEventType;
import com.gic.haoban.manage.api.enums.content.ShareBizType;
import com.gic.haoban.manage.api.enums.content.ShareCustomerSourceType;
......@@ -42,6 +45,8 @@ public class InteractRecordBuilder {
private GoodsInfoOutApiService goodsInfoOutApiService;
@Autowired
private GoodsInfoAdaptor goodsInfoAdaptor;
@Autowired
private EnterpriseWxaLinkService enterpriseWxaLinkService;
/**
* 互动记录描述
......@@ -103,25 +108,7 @@ public class InteractRecordBuilder {
|| MaterialInteractRecordEventType.ADD_SHOPPING_CART.getCode().equals(interactRecord.getEventType())
|| MaterialInteractRecordEventType.ORDER.getCode().equals(interactRecord.getEventType())
|| MaterialInteractRecordEventType.VISIT_MATERIAL.getCode().equals(interactRecord.getEventType())) {
List<List<String>> groupGoodsIds = extendInfo.getGroupGoodsIds();
// 组装商品组数据
if (CollectionUtils.isNotEmpty(groupGoodsIds)) {
List<String> groupGoodsIdList = groupGoodsIds.stream().flatMap(Collection::stream).collect(Collectors.toList());
List<InteractRecordExtendInfoBO.ExtendGoodsInfo> extendGoodsInfos =
this.convertGoodsInfo(groupGoodsIdList, interactRecord.getEnterpriseId());
if (CollectionUtils.isNotEmpty(extendGoodsInfos)) {
Map<String, InteractRecordExtendInfoBO.ExtendGoodsInfo> goodsInfoMap = extendGoodsInfos.stream()
.collect(Collectors.toMap(InteractRecordExtendInfoBO.ExtendGoodsInfo::getGoodsId, Function.identity(),(e,x)->e));
List<List<InteractRecordExtendInfoBO.ExtendGoodsInfo>> groupExtendGoodsInfos = groupGoodsIds.stream()
.map(group -> group.stream()
.map(goodsInfoMap::get)
.filter(Objects::nonNull)
.collect(Collectors.toList()))
.collect(Collectors.toList());
extendInfo.setGroupExtendGoodsInfos(groupExtendGoodsInfos);
extendInfo.setGroupInvalidGoodsNum(groupGoodsIdList.size() - groupExtendGoodsInfos.stream().mapToInt(List::size).sum());
}
}
convertGroupGoods(interactRecord.getEnterpriseId(), extendInfo);
// 浏览商品事件
List<String> visitGoodsIds = extendInfo.getGoodsIds();
if (CollectionUtils.isEmpty(visitGoodsIds)) {
......@@ -151,6 +138,28 @@ public class InteractRecordBuilder {
return extendInfo;
}
private void convertGroupGoods(String enterpriseId, InteractRecordExtendInfoBO extendInfo) {
List<List<String>> groupGoodsIds = extendInfo.getGroupGoodsIds();
// 组装商品组数据
if (CollectionUtils.isNotEmpty(groupGoodsIds)) {
List<String> groupGoodsIdList = groupGoodsIds.stream().flatMap(Collection::stream).collect(Collectors.toList());
List<InteractRecordExtendInfoBO.ExtendGoodsInfo> extendGoodsInfos =
this.convertGoodsInfo(groupGoodsIdList, enterpriseId);
if (CollectionUtils.isNotEmpty(extendGoodsInfos)) {
Map<String, InteractRecordExtendInfoBO.ExtendGoodsInfo> goodsInfoMap = extendGoodsInfos.stream()
.collect(Collectors.toMap(InteractRecordExtendInfoBO.ExtendGoodsInfo::getGoodsId, Function.identity(),(e,x)->e));
List<List<InteractRecordExtendInfoBO.ExtendGoodsInfo>> groupExtendGoodsInfos = groupGoodsIds.stream()
.map(group -> group.stream()
.map(goodsInfoMap::get)
.filter(Objects::nonNull)
.collect(Collectors.toList()))
.collect(Collectors.toList());
extendInfo.setGroupExtendGoodsInfos(groupExtendGoodsInfos);
extendInfo.setGroupInvalidGoodsNum(groupGoodsIdList.size() - groupExtendGoodsInfos.stream().mapToInt(List::size).sum());
}
}
}
private List<InteractRecordExtendInfoBO.ExtendGoodsInfo> convertGoodsInfo(List<String> visitGoodsIds, String enterpriseId) {
if (CollectionUtils.isEmpty(visitGoodsIds)) {
return Collections.emptyList();
......@@ -240,4 +249,44 @@ public class InteractRecordBuilder {
temp.setDealRecordNum(hasOrder ? 1 : 0);
return temp;
}
public Map<String,List<List<String>>> getGroupGoodsIdByWxaLinkIds(List<String> wxaLinkIds) {
if (CollectionUtils.isEmpty(wxaLinkIds)) {
return null;
}
List<EnterpriseWxaLinkDTO> linkList = enterpriseWxaLinkService.listLinkInfo(wxaLinkIds);
if (CollectionUtils.isEmpty(linkList)) {
return null;
}
Map<String, List<List<String>>> map = new HashMap<>();
for (EnterpriseWxaLinkDTO linkInfo : linkList) {
String pageLink = linkInfo.getPageLink();
String id = linkInfo.getId();
if (StringUtils.isBlank(pageLink)) {
return null;
}
String params = JSONObject.parseObject(pageLink).getString("params");
if (StringUtils.isBlank(params)) {
return null;
}
String proIdJSON = JSONObject.parseObject(params).getString("proIdJSON");
if (StringUtils.isBlank(proIdJSON)) {
return null;
}
map.put(id,JSON.parseObject(proIdJSON, new cn.hutool.core.lang.TypeReference<List<List<String>>>() {}));
}
return map;
}
public Map<String,InteractRecordExtendInfoBO> buildGroupGoodsByWxaLinkId(String enterpriseId,List<String> wxaLinkIds) {
Map<String, List<List<String>>> map = getGroupGoodsIdByWxaLinkIds(wxaLinkIds);
Map<String, InteractRecordExtendInfoBO> extendInfoBOMap = new HashMap<>();
map.forEach((wxaLinkId, groupIds) -> {
InteractRecordExtendInfoBO extendInfoBO = new InteractRecordExtendInfoBO();
extendInfoBO.setGroupGoodsIds(groupIds);
convertGroupGoods(enterpriseId, extendInfoBO);
extendInfoBOMap.put(wxaLinkId, extendInfoBO);
});
return extendInfoBOMap;
}
}
package com.gic.haoban.manage.service.service.content.message;
import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.content.api.dto.setting.ContentSettingDTO;
import com.gic.content.api.service.ContentSettingApiService;
import com.gic.enterprise.api.dto.page.EnterpriseWxaLinkDTO;
import com.gic.enterprise.api.service.EnterpriseWxaLinkService;
import com.gic.haoban.manage.api.enums.content.MaterialInteractRecordEventType;
import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordBO;
import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordExtendInfoBO;
......@@ -19,6 +15,7 @@ import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNo
import com.gic.haoban.manage.service.pojo.bo.content.message.InteractRecordMessageBO;
import com.gic.haoban.manage.service.service.content.InteractRecordService;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordBuilder;
import com.gic.haoban.manage.service.service.content.adaptor.InteractRecordMessageBuilder;
import com.gic.haoban.manage.service.util.IntervalUtils;
import com.gic.redis.data.util.RedisUtil;
......@@ -29,10 +26,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
......@@ -50,11 +44,11 @@ public class InteractRecordMessageService {
@Autowired
InteractRecordMessageBuilder interactRecordMessageBuilder;
@Autowired
InteractRecordBuilder interactRecordBuilder;
@Autowired
PotentialCustomerService potentialCustomerService;
@Autowired
ContentSettingApiService contentSettingApiService;
@Autowired
EnterpriseWxaLinkService enterpriseWxaLinkService;
/**
* 处理互动记录
......@@ -200,36 +194,14 @@ public class InteractRecordMessageService {
}
private void saveGroupGoodsId(InteractRecordMessageBO interactRecordMessageBO, InteractRecordBO interactRecordBO) {
if (StringUtils.isBlank(interactRecordMessageBO.getWxaLinkId())) {
return;
}
if (interactRecordBO.getExtendInfo() != null && CollectionUtils.isNotEmpty(interactRecordBO.getExtendInfo().getGroupGoodsIds())) {
return;
}
EnterpriseWxaLinkDTO linkInfo = enterpriseWxaLinkService.getLinkInfo(interactRecordMessageBO.getWxaLinkId());
if (linkInfo == null) {
return;
}
String pageLink = linkInfo.getPageLink();
if (StringUtils.isBlank(pageLink)) {
return;
}
String params = JSONObject.parseObject(pageLink).getString("params");
if (StringUtils.isBlank(params)) {
Map<String, List<List<String>>> map = interactRecordBuilder.getGroupGoodsIdByWxaLinkIds(Lists.newArrayList(interactRecordMessageBO.getWxaLinkId()));
if (MapUtil.isEmpty(map)) {
return;
}
String proIdJSON = JSONObject.parseObject(params).getString("proIdJSON");
if (StringUtils.isBlank(proIdJSON)) {
return;
}
List<List<String>> groupGoodsIds = JSON.parseObject(proIdJSON, new TypeReference<List<String>>() {
});
List<List<String>> groupGoodsIds = map.get(interactRecordMessageBO.getWxaLinkId());
Integer goodsCount = groupGoodsIds.stream().mapToInt(List::size).sum();
if (goodsCount <= 1) {
return;
......
......@@ -2,10 +2,14 @@ package com.gic.haoban.manage.service.service.out.impl.content;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.content.PotentialCustomerDTO;
import com.gic.haoban.manage.api.dto.qdto.content.PotentialCustomerMarkRecordDTO;
import com.gic.haoban.manage.api.dto.qdto.content.PotentialCustomerQDTO;
import com.gic.haoban.manage.api.enums.content.InteractRecordExtendInfoDTO;
import com.gic.haoban.manage.api.enums.content.ShareBizType;
import com.gic.haoban.manage.api.service.content.PotentialCustomerApiService;
import com.gic.haoban.manage.service.pojo.bo.content.InteractRecordExtendInfoBO;
import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO;
import com.gic.haoban.manage.service.pojo.qo.content.PotentialCustomerQO;
import com.gic.haoban.manage.service.service.content.PotentialCustomerService;
......@@ -16,6 +20,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
......@@ -46,6 +52,10 @@ public class PotentialCustomerApiServiceImpl implements PotentialCustomerApiServ
if (CollectionUtils.isEmpty(customerPage.getResult())) {
return ServiceResponse.success(new Page<>());
}
List<String> wxaLinkIds = customerPage.getResult().stream()
.filter(item -> Objects.equals(item.getBizType(), ShareBizType.MULTIPLE_GOODS.getCode()))
.map(PotentialCustomerBO::getBizId).collect(Collectors.toList());
Map<String, InteractRecordExtendInfoBO> extendInfoBOMap = interactRecordBuilder.buildGroupGoodsByWxaLinkId(potentialCustomerQDTO.getEnterpriseId(), wxaLinkIds);
Page<PotentialCustomerDTO> resultPage = new Page<>();
resultPage.setTotalCount(customerPage.getTotalCount());
resultPage.setCurrentPage(potentialCustomerQDTO.getPageNum());
......@@ -57,6 +67,10 @@ public class PotentialCustomerApiServiceImpl implements PotentialCustomerApiServ
BeanUtils.copyProperties(item, temp);
temp.setPotentialCustomerId(item.getId());
temp.setDesc(interactRecordBuilder.buildDesc(item.getChannelSource(), item.getShareSource(),item.getEventType(), item.getBizType()));
InteractRecordExtendInfoBO extendInfoBO = extendInfoBOMap.get(item.getBizId());
if (extendInfoBO != null) {
temp.setExtendInfo(EntityUtil.changeEntityByJSON(InteractRecordExtendInfoDTO.class, extendInfoBO));
}
return temp;
})
.collect(Collectors.toList());
......
......@@ -3,6 +3,7 @@ package com.gic.haoban.manage.web.controller.content;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.EntityUtil;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.content.api.dto.material.ContentMaterialBaseDTO;
import com.gic.haoban.manage.api.dto.content.PotentialCustomerDTO;
......@@ -17,6 +18,7 @@ import com.gic.haoban.manage.web.qo.content.potential.PotentialCustomerMarkRecor
import com.gic.haoban.manage.web.qo.content.potential.PotentialCustomerQO;
import com.gic.haoban.manage.web.vo.content.ContentMaterialInfoVO;
import com.gic.haoban.manage.web.vo.content.SimpleGoodsInfoVO;
import com.gic.haoban.manage.web.vo.content.potential.InteractRecordExtendInfoVo;
import com.gic.haoban.manage.web.vo.content.potential.PotentialCustomerVO;
import com.gic.store.goods.dto.goods.GoodsInfoSimpleDTO;
import com.gic.store.goods.dto.goods.GoodsSpuInfoDTO;
......@@ -111,6 +113,7 @@ public class PotentialCustomerController {
PotentialCustomerVO temp = new PotentialCustomerVO();
BeanUtils.copyProperties(item, temp);
temp.setPotentialCustomerId(item.getPotentialCustomerId());
temp.setExtendInfo(EntityUtil.changeEntityByJSON(InteractRecordExtendInfoVo.class,item.getExtendInfo()));
if (ShareBizType.MATERIAL.getCode().equals(item.getBizType())) {
ContentMaterialBaseDTO contentMaterialBaseDTO = materialInfoMap.get(Long.parseLong(item.getBizId()));
if (contentMaterialBaseDTO != null) {
......
package com.gic.haoban.manage.web.vo.content.potential;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
@Data
public class InteractRecordExtendInfoVo implements Serializable {
private static final long serialVersionUID = 1577766149535235456L;
/**
* 按组分享素材扩展商品信息
*/
private List<List<ExtendGoodsInfo>> groupExtendGoodsInfos;
/**
* 按组分享失效商品数量
*/
private Integer groupInvalidGoodsNum;
@Data
public static class ExtendGoodsInfo implements Serializable {
/**
* 商品id
*/
private String goodsId;
/**
* 商品名称
*/
private String goodsName;
/**
* 商品主图
*/
private String goodsImageUrl;
/**
* 商品货号
*/
private String goodsCode;
/**
* 商品规格 红色,S; 白色,S
*/
private String goodsNorm;
/**
* 订单项数量
*/
private Integer orderNum;
/**
* 商品单价
*/
private BigDecimal salePrice;
}
}
......@@ -2,6 +2,7 @@ package com.gic.haoban.manage.web.vo.content.potential;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gic.haoban.manage.api.enums.content.InteractRecordExtendInfoDTO;
import com.gic.haoban.manage.web.vo.content.ContentMaterialInfoVO;
import com.gic.haoban.manage.web.vo.content.SimpleGoodsInfoVO;
import lombok.Data;
......@@ -120,4 +121,9 @@ public class PotentialCustomerVO implements Serializable {
* 业务id
*/
private String bizId;
/**
* 扩展信息
*/
private InteractRecordExtendInfoVo extendInfo;
}
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