Commit eaae7496 by songyinghui

feat: 销售线索按客户去重

parent f4364c20
...@@ -21,6 +21,7 @@ import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO; ...@@ -21,6 +21,7 @@ import com.gic.wechat.api.dto.qywx.QywxXcxSendMessageDTO;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService; import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
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.collections.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -86,6 +87,7 @@ public class PotentialCustomerNotifyBuilder { ...@@ -86,6 +87,7 @@ public class PotentialCustomerNotifyBuilder {
List<String> clerkIds = context.getCustomerStaticsBos() List<String> clerkIds = context.getCustomerStaticsBos()
.stream() .stream()
.map(PotentialCustomerStaticsBO::getClerkId) .map(PotentialCustomerStaticsBO::getClerkId)
.distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
context.setClerkIds(clerkIds); context.setClerkIds(clerkIds);
List<StaffClerkRelationDTO> staffClerkRelations = staffClerkRelationService.listByClerkIds(context.getClerkIds()); List<StaffClerkRelationDTO> staffClerkRelations = staffClerkRelationService.listByClerkIds(context.getClerkIds());
...@@ -141,7 +143,6 @@ public class PotentialCustomerNotifyBuilder { ...@@ -141,7 +143,6 @@ public class PotentialCustomerNotifyBuilder {
Map<String, PotentialCustomerStaticsBO> customerStaticsBOMap = context.getCustomerStaticsBos() Map<String, PotentialCustomerStaticsBO> customerStaticsBOMap = context.getCustomerStaticsBos()
.stream() .stream()
.collect(Collectors.toMap(PotentialCustomerStaticsBO::getClerkId, Function.identity(), (v1, v2) -> v1)); .collect(Collectors.toMap(PotentialCustomerStaticsBO::getClerkId, Function.identity(), (v1, v2) -> v1));
Map<String, TabHaobanClerkMainStoreRelated> clerkMainStoreMap = new HashMap<>();
// 按staffId 聚合 // 按staffId 聚合
Map<String, List<StaffClerkRelationDTO>> staffRelationMap = context.getStaffClerkRelations() Map<String, List<StaffClerkRelationDTO>> staffRelationMap = context.getStaffClerkRelations()
...@@ -151,6 +152,11 @@ public class PotentialCustomerNotifyBuilder { ...@@ -151,6 +152,11 @@ public class PotentialCustomerNotifyBuilder {
return staticsBO != null && staticsBO.getNum() != null && staticsBO.getNum() > 0; return staticsBO != null && staticsBO.getNum() != null && staticsBO.getNum() > 0;
}) })
.collect(Collectors.groupingBy(StaffClerkRelationDTO::getStaffId)); .collect(Collectors.groupingBy(StaffClerkRelationDTO::getStaffId));
if (MapUtils.isEmpty(staffRelationMap)) {
log.info("企业下的销售线索统计为空 {}", context.getEnterpriseId());
return;
}
// 按成员分组
for (Map.Entry<String, List<StaffClerkRelationDTO>> entry : staffRelationMap.entrySet()) { for (Map.Entry<String, List<StaffClerkRelationDTO>> entry : staffRelationMap.entrySet()) {
if (CollectionUtils.isEmpty(entry.getValue())) { if (CollectionUtils.isEmpty(entry.getValue())) {
log.info("成员不存在有数值的绑定关系 staffIf:{}", entry.getKey()); log.info("成员不存在有数值的绑定关系 staffIf:{}", entry.getKey());
......
...@@ -285,9 +285,9 @@ ...@@ -285,9 +285,9 @@
</select> </select>
<select id="staticsClerkInteractRecordNew" resultType="com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO"> <select id="staticsClerkInteractRecordNew" resultType="com.gic.haoban.manage.service.pojo.bo.content.PotentialCustomerStaticsBO">
select clerk_id clerkId, count(1) num select clerk_id clerkId, count(DISTINCT member_id) num
from tab_haoban_interact_record from tab_haoban_interact_record
where delete_flag = 0 where delete_flag = 0 and member_id is not null
<if test="clerkId != null and clerkId != ''"> <if test="clerkId != null and clerkId != ''">
and clerk_id = #{clerkId} and clerk_id = #{clerkId}
</if> </if>
......
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