Commit c8423da3 by songyinghui

feat: 销售线索 列表

parent c2b65cf0
...@@ -398,4 +398,13 @@ public interface TabHaobanExternalClerkRelatedMapper { ...@@ -398,4 +398,13 @@ public interface TabHaobanExternalClerkRelatedMapper {
*/ */
List<String> queryExternalUserIdWithStaffId(@Param("staffId") String staffId); List<String> queryExternalUserIdWithStaffId(@Param("staffId") String staffId);
/**
* 查询会员与导购的好友关系
* @param clerkId
* @param memberIds
* @return
*/
List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(@Param("clerkId") String clerkId, @Param("memberIds") List<String> memberIds);
} }
\ No newline at end of file
...@@ -100,4 +100,16 @@ public class PotentialCustomerBO { ...@@ -100,4 +100,16 @@ public class PotentialCustomerBO {
* 更新时间 * 更新时间
*/ */
private Date updateTime; private Date updateTime;
/**
* 导购与会员是否有好友
* 1 是好友; 0不是
*/
private Integer hasMemberRelation;
/**
* 会员全渠道成交
* 1 有过成交; 0 没有成交
*/
private Integer dealRecord;
} }
...@@ -90,4 +90,12 @@ public interface ExternalClerkRelatedService { ...@@ -90,4 +90,12 @@ public interface ExternalClerkRelatedService {
*/ */
List<String> queryExternalRelatedWithStaffId(String staffId); List<String> queryExternalRelatedWithStaffId(String staffId);
/***
* 查询会员与导购的关系
* @param clerkId
* @param memberIds
* @return
*/
List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(String clerkId, List<String> memberIds);
} }
...@@ -5,19 +5,18 @@ import com.gic.api.base.commons.Page; ...@@ -5,19 +5,18 @@ import com.gic.api.base.commons.Page;
import com.gic.commons.util.UniqueIdUtils; import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.common.utils.PageUtil; import com.gic.haoban.common.utils.PageUtil;
import com.gic.haoban.manage.service.dao.mapper.content.TabHaobanPotentialCustomerMapper; import com.gic.haoban.manage.service.dao.mapper.content.TabHaobanPotentialCustomerMapper;
import com.gic.haoban.manage.service.entity.TabHaobanExternalClerkRelated;
import com.gic.haoban.manage.service.entity.content.TabHaobanPotentialCustomer; import com.gic.haoban.manage.service.entity.content.TabHaobanPotentialCustomer;
import com.gic.haoban.manage.service.pojo.bo.NoticeMessageBO;
import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO; import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerBO;
import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO; import com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO;
import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext; import com.gic.haoban.manage.service.pojo.bo.content.context.PotentialCustomerNotifyContext;
import com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO; import com.gic.haoban.manage.service.pojo.qo.content.InteractRecordQO;
import com.gic.haoban.manage.service.pojo.qo.content.PotentialCustomerQO; import com.gic.haoban.manage.service.pojo.qo.content.PotentialCustomerQO;
import com.gic.haoban.manage.service.service.ExternalClerkRelatedService;
import com.gic.haoban.manage.service.service.content.InteractRecordService; 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.PotentialCustomerService;
import com.gic.haoban.manage.service.service.content.adaptor.PotentialCustomerNotifyBuilder; import com.gic.haoban.manage.service.service.content.adaptor.PotentialCustomerNotifyBuilder;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -26,9 +25,11 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -26,9 +25,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -48,7 +49,7 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService { ...@@ -48,7 +49,7 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
@Autowired @Autowired
private InteractRecordService interactRecordService; private InteractRecordService interactRecordService;
@Autowired @Autowired
private NoticeMessageService noticeMessageService; private ExternalClerkRelatedService externalClerkRelatedService;
/** /**
...@@ -67,7 +68,57 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService { ...@@ -67,7 +68,57 @@ public class PotentialCustomerServiceImpl implements PotentialCustomerService {
PageHelper.startPage(potentialCustomerQO.getPageNum(), potentialCustomerQO.getPageSize()); PageHelper.startPage(potentialCustomerQO.getPageNum(), potentialCustomerQO.getPageSize());
com.github.pagehelper.Page<TabHaobanPotentialCustomer> pageResult = com.github.pagehelper.Page<TabHaobanPotentialCustomer> pageResult =
(com.github.pagehelper.Page<TabHaobanPotentialCustomer>) potentialCustomerMapper.queryPotentialCustomerList(potentialCustomerQO); (com.github.pagehelper.Page<TabHaobanPotentialCustomer>) potentialCustomerMapper.queryPotentialCustomerList(potentialCustomerQO);
return PageUtil.changePageHelperToCurrentPage(pageResult, PotentialCustomerBO.class); Page<PotentialCustomerBO> customerBOPage = PageUtil.changePageHelperToCurrentPage(pageResult, PotentialCustomerBO.class);
if (CollectionUtils.isEmpty(customerBOPage.getResult())) {
log.info("查询销售线索列表为空 params: {}", JSON.toJSONString(potentialCustomerQO));
return customerBOPage;
}
List<String> memberIds = customerBOPage.getResult()
.stream()
.map(PotentialCustomerBO::getMemberId)
.distinct()
.collect(Collectors.toList());
Map<String, Integer> clerkMemberRelationMap = this.queryMemberRelation(potentialCustomerQO.getClerkId(), memberIds, potentialCustomerQO.getHasMemberRelation());
// 构建是否是会员
for (PotentialCustomerBO potentialCustomerBO : customerBOPage.getResult()) {
// 默认未成交过
potentialCustomerBO.setDealRecord(0);
if (potentialCustomerBO.getDealRecordNum() != null && potentialCustomerBO.getDealRecordNum() > 0) {
potentialCustomerBO.setDealRecord(1);
}
if (potentialCustomerQO.getHasMemberRelation() != null) {
// 查询条件是有好友关系的
potentialCustomerBO.setHasMemberRelation(1);
continue;
}
// 获取有好友关系的
Integer hasRelation = clerkMemberRelationMap.get(potentialCustomerBO.getMemberId());
potentialCustomerBO.setHasMemberRelation(Optional.ofNullable(hasRelation).orElse(0));
}
return customerBOPage;
}
/**
* 查询与导购的关系
*
* @param clerkId
* @param memberIds
* @return
*/
private Map<String, Integer> queryMemberRelation(String clerkId, List<String> memberIds, Integer hasMemberRelation) {
if (hasMemberRelation != null) {
log.info("按好友条件搜索 无须查询");
return Collections.emptyMap();
}
List<TabHaobanExternalClerkRelated> clerkRelateds = externalClerkRelatedService.queryClerkMemberRelations(clerkId, memberIds);
if (CollectionUtils.isEmpty(clerkRelateds)) {
log.info("查询导购与本批次会员不存在好友关系 clerkId:{}", clerkId);
return Collections.emptyMap();
}
return clerkRelateds
.stream()
.collect(Collectors.toMap(TabHaobanExternalClerkRelated::getMemberId, item -> 1, (v1, v2) -> v1));
} }
/** /**
......
...@@ -501,4 +501,23 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ ...@@ -501,4 +501,23 @@ public class ExternalClerkRelatedServiceImpl implements ExternalClerkRelatedServ
public List<String> queryExternalRelatedWithStaffId(String staffId) { public List<String> queryExternalRelatedWithStaffId(String staffId) {
return this.mapper.queryExternalUserIdWithStaffId(staffId); return this.mapper.queryExternalUserIdWithStaffId(staffId);
} }
/***
* 查询会员与导购的关系
* @param clerkId
* @param memberIds
* @return
*/
@Override
public List<TabHaobanExternalClerkRelated> queryClerkMemberRelations(String clerkId, List<String> memberIds) {
if (StringUtils.isBlank(clerkId)) {
logger.info("查询导购与会员的关系,导购id不存在 {}", clerkId);
return Collections.emptyList();
}
if (CollectionUtils.isEmpty(memberIds)) {
logger.info("查询导购与会员的关系,会员id数组为空 {}", clerkId);
return Collections.emptyList();
}
return this.mapper.queryClerkMemberRelations(clerkId, memberIds);
}
} }
...@@ -768,4 +768,15 @@ ...@@ -768,4 +768,15 @@
and status_flag in (1, 3, 4); and status_flag in (1, 3, 4);
</select> </select>
<select id="queryClerkMemberRelations" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from tab_haoban_external_clerk_related
where clerk_id = #{clerkId}
and status_flag in (1, 3, 4)
and member_id in
<foreach collection="memberIds" item="memberId" open="(" close=")" separator=",">
#{memberId}
</foreach>
</select>
</mapper> </mapper>
\ No newline at end of file
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.Page;
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;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* @Author MUSI
* @Date 2023/3/30 10:15 PM
* @Description
* @Version
**/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext-conf.xml"})
public class PotentialCustomerServiceTest {
@Autowired
PotentialCustomerService potentialCustomerService;
String eid = "ff8080815dacd3a2015dacd3ef5c0000";
String wxEid = "ca66a01b79474c40b3e7c7f93daf1a3b";
String staffId = "e608b51b267e4943b87e222a343b4f25";
String clerkId = "fbc508e395f846ef9005852c420e1c4f";
String memberId = "ff8080818147efc8018148d1759903c8";
@Test
public void queryPotentialCustomerTest(){
PotentialCustomerQO potentialCustomerQO = new PotentialCustomerQO();
potentialCustomerQO.setEnterpriseId(eid);
potentialCustomerQO.setWxEnterpriseId(wxEid);
potentialCustomerQO.setClerkId(clerkId);
potentialCustomerQO.setSeeFlag(0);
potentialCustomerQO.setStarFlag(0);
Page<PotentialCustomerBO> customerBOPage =
potentialCustomerService.queryPotentialCustomerPage(potentialCustomerQO);
System.out.println(JSON.toJSONString(customerBOPage));
}
}
package com.gic.haoban.manage.web.controller.content; 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.Page;
import com.gic.api.base.commons.ServiceResponse; import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.webapi.reponse.RestResponse; import com.gic.commons.webapi.reponse.RestResponse;
...@@ -10,6 +11,7 @@ import com.gic.haoban.manage.api.dto.qdto.content.PotentialCustomerQDTO; ...@@ -10,6 +11,7 @@ import com.gic.haoban.manage.api.dto.qdto.content.PotentialCustomerQDTO;
import com.gic.haoban.manage.api.enums.content.ShareBizType; import com.gic.haoban.manage.api.enums.content.ShareBizType;
import com.gic.haoban.manage.api.service.content.PotentialCustomerApiService; import com.gic.haoban.manage.api.service.content.PotentialCustomerApiService;
import com.gic.haoban.manage.web.controller.content.adaptor.ContentMaterialAdaptor; import com.gic.haoban.manage.web.controller.content.adaptor.ContentMaterialAdaptor;
import com.gic.haoban.manage.web.controller.content.adaptor.MaterialDataAdaptor;
import com.gic.haoban.manage.web.qo.content.potential.PotentialCustomerMarkRecordVO; import com.gic.haoban.manage.web.qo.content.potential.PotentialCustomerMarkRecordVO;
import com.gic.haoban.manage.web.qo.content.potential.PotentialCustomerQO; 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.ContentMaterialInfoVO;
...@@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -23,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -37,6 +40,11 @@ public class PotentialCustomerController { ...@@ -37,6 +40,11 @@ public class PotentialCustomerController {
private PotentialCustomerApiService potentialCustomerApiService; private PotentialCustomerApiService potentialCustomerApiService;
@Autowired @Autowired
ContentMaterialAdaptor contentMaterialAdaptor; ContentMaterialAdaptor contentMaterialAdaptor;
@Autowired
MaterialDataAdaptor materialDataAdaptor;
/** /**
* 销售线索列表 * 销售线索列表
* *
...@@ -51,6 +59,7 @@ public class PotentialCustomerController { ...@@ -51,6 +59,7 @@ public class PotentialCustomerController {
ServiceResponse<Page<PotentialCustomerDTO>> serviceResponse = ServiceResponse<Page<PotentialCustomerDTO>> serviceResponse =
potentialCustomerApiService.queryPotentialCustomer(searchQDTO); potentialCustomerApiService.queryPotentialCustomer(searchQDTO);
if (!serviceResponse.isSuccess()) { if (!serviceResponse.isSuccess()) {
log.info("查询销售线索异常 {}", JSON.toJSONString(serviceResponse));
return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage()); return RestResponse.failure(serviceResponse.getCode(), serviceResponse.getMessage());
} }
List<PotentialCustomerDTO> customerDTOS = serviceResponse.getResult().getResult(); List<PotentialCustomerDTO> customerDTOS = serviceResponse.getResult().getResult();
...@@ -61,6 +70,13 @@ public class PotentialCustomerController { ...@@ -61,6 +70,13 @@ public class PotentialCustomerController {
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<Long, ContentMaterialBaseDTO> materialInfoMap = contentMaterialAdaptor.queryMaterialInfoMap(potentialCustomerQO.getEnterpriseId(), materialIds); Map<Long, ContentMaterialBaseDTO> materialInfoMap = contentMaterialAdaptor.queryMaterialInfoMap(potentialCustomerQO.getEnterpriseId(), materialIds);
List<String> memberIds = customerDTOS
.stream()
.filter(item -> ShareBizType.MATERIAL.getCode().equals(item.getBizType()))
.map(PotentialCustomerDTO::getMemberId)
.collect(Collectors.toList());
Map<String, Integer> memberVisitMap =
materialDataAdaptor.queryMemberVisitMap(potentialCustomerQO.getEnterpriseId(), null, potentialCustomerQO.getClerkId(), memberIds);
List<PotentialCustomerVO> customerVOS = customerDTOS List<PotentialCustomerVO> customerVOS = customerDTOS
.stream() .stream()
.map(item -> { .map(item -> {
...@@ -73,6 +89,8 @@ public class PotentialCustomerController { ...@@ -73,6 +89,8 @@ public class PotentialCustomerController {
BeanUtils.copyProperties(contentMaterialBaseDTO, contentMaterialInfoVO); BeanUtils.copyProperties(contentMaterialBaseDTO, contentMaterialInfoVO);
temp.setContentMaterialInfoVO(contentMaterialInfoVO); temp.setContentMaterialInfoVO(contentMaterialInfoVO);
} }
Integer visitNum = memberVisitMap.get(item.getMemberId());
temp.setVisitNum(Optional.ofNullable(visitNum).orElse(0));
return temp; return temp;
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
...@@ -83,7 +101,6 @@ public class PotentialCustomerController { ...@@ -83,7 +101,6 @@ public class PotentialCustomerController {
} }
/** /**
* 标记销售线索为已看 * 标记销售线索为已看
* *
......
...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO; ...@@ -11,6 +11,7 @@ import com.gic.haoban.manage.web.vo.content.statistics.MaterialClerkUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialDataOverviewVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialDataOverviewVO;
import com.gic.haoban.manage.web.vo.content.statistics.MaterialStoreUsedDataVO; import com.gic.haoban.manage.web.vo.content.statistics.MaterialStoreUsedDataVO;
import com.gic.haoban.manage.web.vo.content.statistics.bo.MaterialTodayDataBO; import com.gic.haoban.manage.web.vo.content.statistics.bo.MaterialTodayDataBO;
import com.gic.haoban.manage.web.vo.content.statistics.bo.MemberVisitMaterialBO;
import com.gic.haoban.manage.web.vo.content.statistics.report.MaterialPersonalUsedDataVO; import com.gic.haoban.manage.web.vo.content.statistics.report.MaterialPersonalUsedDataVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -22,6 +23,8 @@ import java.util.Collections; ...@@ -22,6 +23,8 @@ import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* @Author MUSI * @Author MUSI
...@@ -79,6 +82,11 @@ public class MaterialDataAdaptor { ...@@ -79,6 +82,11 @@ public class MaterialDataAdaptor {
*/ */
private static final String MATERIAL_AREA_MONTH_DATA = "data_cms_store_month_report_total"; private static final String MATERIAL_AREA_MONTH_DATA = "data_cms_store_month_report_total";
/**
* 会员最近30天访问素材总数
*/
private static final String MEMBER_RECENTLY_30_DAY_VISIT = "data_matl_haoban_user_30day_stats_real";
/** /**
* 查询素材首页使用数据 * 查询素材首页使用数据
...@@ -340,6 +348,7 @@ public class MaterialDataAdaptor { ...@@ -340,6 +348,7 @@ public class MaterialDataAdaptor {
/** /**
* 取经数据概览数据 * 取经数据概览数据
*
* @return * @return
*/ */
public MaterialStoreUsedDataVO queryMaterialAreaOverviewData(String enterpriseId, String clerkId, public MaterialStoreUsedDataVO queryMaterialAreaOverviewData(String enterpriseId, String clerkId,
...@@ -397,4 +406,37 @@ public class MaterialDataAdaptor { ...@@ -397,4 +406,37 @@ public class MaterialDataAdaptor {
return Collections.emptyMap(); return Collections.emptyMap();
} }
/**
* 会员最近30天的浏览素材数量
*
* @param enterpriseId
* @param storeId
* @param clerkId
* @param memberIds
* @return
*/
public Map<String, Integer> queryMemberVisitMap(String enterpriseId, String storeId, String clerkId, List<String> memberIds) {
Map<String, Object> params = new HashMap<>();
Map<String, Object> inlineParams = new HashMap<>();
params.put("inFields", inlineParams);
if (StringUtils.isNotBlank(clerkId)) {
inlineParams.put("clerkId", clerkId);
}
inlineParams.put("enterprsieId", enterpriseId);
inlineParams.put("customerId", StringUtils.join(memberIds, ","));
Map<String, Object> result = this.doHttp(JSON.toJSONString(params), MEMBER_RECENTLY_30_DAY_VISIT);
if (result.get("data") == null) {
return Collections.emptyMap();
}
List<MemberVisitMaterialBO> memberVisitMaterialBos = JSON.parseArray(JSON.toJSONString(result.get("data")), MemberVisitMaterialBO.class);
if (CollectionUtils.isEmpty(memberVisitMaterialBos)) {
return Collections.emptyMap();
}
return memberVisitMaterialBos
.stream()
.collect(Collectors.toMap(MemberVisitMaterialBO::getCustomerId, item -> Optional.ofNullable(item.getMatlNum30Day())
.map(Integer::new).orElse(0), (v1, v2) -> v1));
}
} }
package com.gic.haoban.manage.web.vo.content.statistics.bo;
import lombok.Data;
import java.io.Serializable;
/**
* @Author MUSI
* @Date 2023/3/30 10:59 PM
* @Description
* @Version
**/
@Data
public class MemberVisitMaterialBO implements Serializable {
private String enterpriseId;
private String clerkId;
/**
* 会员id
*/
private String customerId;
/**
* 最近30天访问素材数
*/
private String matlNum30Day;
}
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