添加店均拓客数。

dev_0531
kevin jiang 6 years ago
parent 7339bfdb3a
commit fb0570eeb5

@ -98,4 +98,7 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
@Param("type") Integer type); @Param("type") Integer type);
Long selectSellerCustomerRelation(@Param("customerId") Long customerId, @Param("userId") Long userId, @Param("storeId") Long storeId); Long selectSellerCustomerRelation(@Param("customerId") Long customerId, @Param("userId") Long userId, @Param("storeId") Long storeId);
Integer countStoreCustomers(@Param("customerId") Long customerId, @Param("userId") Long userId, @Param("storeId") Long storeId);
} }

@ -37,4 +37,9 @@ public class RetailOrganizationalVO extends DataVO{
* *
*/ */
private Integer delRate; private Integer delRate;
/**
*
*/
private Integer avgStoreCustomer;
} }

@ -21,4 +21,13 @@ public interface PoiCustomerContactDataStatMapper extends BaseMapper<PoiCustomer
List<TableAnalysisDTO> selectSumApplyCustomer(@Param("shopIds")List<Long> storeIds, @Param("count")Integer count, List<TableAnalysisDTO> selectSumApplyCustomer(@Param("shopIds")List<Long> storeIds, @Param("count")Integer count,
@Param("startDate") Date selectStartTime, @Param("endDate")Date selectEndTime); @Param("startDate") Date selectStartTime, @Param("endDate")Date selectEndTime);
/**
*
* @param storeIds ID
* @return
* @author dexiang.jiang
* @date 2020/05/17 12:42
*/
Integer sumNegativeFeedbackCntByStoreIds(@Param("storeIds") List<Long> storeIds);
} }

@ -279,6 +279,20 @@ public class RetailCompanyService {
return poiStoreDOMapper.selectShopByCustomerIds(new ArrayList<>(customerIds)); return poiStoreDOMapper.selectShopByCustomerIds(new ArrayList<>(customerIds));
} }
/**
*
*
* @param orgId id
* @return ID
* @author dexiang.jiang
* @date 2020/05/17 12:07
*/
public List<Long> selectStoreIdListByCompanyId(Long orgId) {
//查询客户
List<Long> storeIds = poiStoreDOMapper.selectShopIdByCustomerId(orgId);
return storeIds;
}
/** /**
* *
* *
@ -334,8 +348,7 @@ public class RetailCompanyService {
organizationalVO.setRetailCompany(org.getName()); organizationalVO.setRetailCompany(org.getName());
//查询零售公司的门店 //查询零售公司的门店
List<PoiStore> list1 = selectShopByCompany(org.getId()); List<Long> stores = selectStoreIdListByCompanyId(org.getId());
List<Long> stores = list1.stream().map(PoiStore::getId).collect(Collectors.toList());
if(CollectionUtils.isEmpty(stores)){ if(CollectionUtils.isEmpty(stores)){
organizationalVO.setAllCustomer(0); organizationalVO.setAllCustomer(0);
@ -346,6 +359,7 @@ public class RetailCompanyService {
organizationalVO.setAvgNewEffectiveCustomer(0); organizationalVO.setAvgNewEffectiveCustomer(0);
organizationalVO.setNewCustomer(0); organizationalVO.setNewCustomer(0);
organizationalVO.setNewEffectiveCustomer(0); organizationalVO.setNewEffectiveCustomer(0);
organizationalVO.setAvgStoreCustomer(0);
list.add(organizationalVO); list.add(organizationalVO);
return; return;
} }
@ -364,24 +378,26 @@ public class RetailCompanyService {
QueryWrapper<OpSellerCustomerRelation> wrapper4 = new QueryWrapper<>(); QueryWrapper<OpSellerCustomerRelation> wrapper4 = new QueryWrapper<>();
wrapper4.in("store_id", stores); wrapper4.in("store_id", stores);
wrapper4.eq("type", 1); wrapper4.eq("type", 1);
List<OpSellerCustomerRelation> opRelations1 = opSellerCustomerRelationDOMapper.selectList(wrapper4); Integer countAble = opSellerCustomerRelationDOMapper.selectCount(wrapper4);
long countAble = opRelations1.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count(); // long countAble = opRelations1.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
organizationalVO.setEffectiveCustomer((int) countAble); organizationalVO.setEffectiveCustomer(countAble);
//计算新增客户数据 //计算新增客户数据
newCustomerStore(startTime, endTime, organizationalVO, stores); newCustomerStore(startTime, endTime, organizationalVO, stores);
//被拉黑的客户数 //被拉黑的客户数
if (!stores.isEmpty()) {
// stores.add(-1L);
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>(); QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
if (stores.isEmpty()) {
stores.add(-1L);
}
wrapper3.in("store_id", stores); wrapper3.in("store_id", stores);
List<PoiCustomerContactDataStat> dataStats = poiCustomerContactDataStatMapper.selectList(wrapper3); Integer allAge = poiCustomerContactDataStatMapper.sumNegativeFeedbackCntByStoreIds(stores);
long allAge = dataStats.stream().mapToLong(PoiCustomerContactDataStat::getNegativeFeedbackCnt).sum();
organizationalVO.setDelCustomer(allAge);
organizationalVO.setDelRate(check(new Long(allAge), count));
}
organizationalVO.setDelCustomer((int) allAge); Integer avgStoreCustomer = organizationalVO.getAllCustomer() / stores.size();
organizationalVO.setDelRate(check(allAge, count)); organizationalVO.setAvgStoreCustomer(avgStoreCustomer);
list.add(organizationalVO); list.add(organizationalVO);
}); });
OrganizationVO vo = new OrganizationVO(); OrganizationVO vo = new OrganizationVO();

@ -59,4 +59,15 @@ public interface PoiStoreDOMapper extends BaseMapper<PoiStore> {
* *
*/ */
String selectProvinceName(@Param("cityId")Long cityId); String selectProvinceName(@Param("cityId")Long cityId);
/**
*
*
* @param orgId id
* @return ID
* @author dexiang.jiang
* @date 2020/05/17 12:07
*/
List<Long> selectShopIdByCustomerId(@Param("orgId")Long orgId);
} }

@ -35,4 +35,13 @@
group by store_id having sum(new_contact_cnt) &lt;= #{count} group by store_id having sum(new_contact_cnt) &lt;= #{count}
</select> </select>
<select id="sumNegativeFeedbackCntByStoreIds" resultType="java.lang.Integer">
select
SUM(negative_feedback_cnt)
from poi_customer_contact_data_stat t1 where
t1.store_id in
<foreach collection="storeIds" separator="," item="item" index="index" close=")" open="(">
#{item}
</foreach>
</select>
</mapper> </mapper>

@ -172,4 +172,15 @@
<!-- </if>--> <!-- </if>-->
</select> </select>
<select id="selectShopIdByCustomerId" resultType="java.lang.Long">
select t5.id from privilage_organizational t,privilage_organizational_domain t2,privilage_domain t3,privilage_domain_entity t4,poi_store t5
where t.parent_id = #{orgId}
and t.id = t2.org_id
and t2.domain_id = t3.id
and t3.id = t4.domain_id
and t4.entity_id = t5.id
and t4.type = 3 ;
</select>
</mapper> </mapper>

Loading…
Cancel
Save