添加店均拓客数。

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);
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 avgStoreCustomer;
}

@ -21,4 +21,13 @@ public interface PoiCustomerContactDataStatMapper extends BaseMapper<PoiCustomer
List<TableAnalysisDTO> selectSumApplyCustomer(@Param("shopIds")List<Long> storeIds, @Param("count")Integer count,
@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));
}
/**
*
*
* @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());
//查询零售公司的门店
List<PoiStore> list1 = selectShopByCompany(org.getId());
List<Long> stores = list1.stream().map(PoiStore::getId).collect(Collectors.toList());
List<Long> stores = selectStoreIdListByCompanyId(org.getId());
if(CollectionUtils.isEmpty(stores)){
organizationalVO.setAllCustomer(0);
@ -346,6 +359,7 @@ public class RetailCompanyService {
organizationalVO.setAvgNewEffectiveCustomer(0);
organizationalVO.setNewCustomer(0);
organizationalVO.setNewEffectiveCustomer(0);
organizationalVO.setAvgStoreCustomer(0);
list.add(organizationalVO);
return;
}
@ -364,24 +378,26 @@ public class RetailCompanyService {
QueryWrapper<OpSellerCustomerRelation> wrapper4 = new QueryWrapper<>();
wrapper4.in("store_id", stores);
wrapper4.eq("type", 1);
List<OpSellerCustomerRelation> opRelations1 = opSellerCustomerRelationDOMapper.selectList(wrapper4);
long countAble = opRelations1.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
organizationalVO.setEffectiveCustomer((int) countAble);
Integer countAble = opSellerCustomerRelationDOMapper.selectCount(wrapper4);
// long countAble = opRelations1.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
organizationalVO.setEffectiveCustomer(countAble);
//计算新增客户数据
newCustomerStore(startTime, endTime, organizationalVO, stores);
//被拉黑的客户数
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
if (stores.isEmpty()) {
stores.add(-1L);
if (!stores.isEmpty()) {
// stores.add(-1L);
QueryWrapper<PoiCustomerContactDataStat> wrapper3 = new QueryWrapper<>();
wrapper3.in("store_id", stores);
Integer allAge = poiCustomerContactDataStatMapper.sumNegativeFeedbackCntByStoreIds(stores);
organizationalVO.setDelCustomer(allAge);
organizationalVO.setDelRate(check(new Long(allAge), count));
}
wrapper3.in("store_id", stores);
List<PoiCustomerContactDataStat> dataStats = poiCustomerContactDataStatMapper.selectList(wrapper3);
long allAge = dataStats.stream().mapToLong(PoiCustomerContactDataStat::getNegativeFeedbackCnt).sum();
organizationalVO.setDelCustomer((int) allAge);
organizationalVO.setDelRate(check(allAge, count));
Integer avgStoreCustomer = organizationalVO.getAllCustomer() / stores.size();
organizationalVO.setAvgStoreCustomer(avgStoreCustomer);
list.add(organizationalVO);
});
OrganizationVO vo = new OrganizationVO();

@ -59,4 +59,15 @@ public interface PoiStoreDOMapper extends BaseMapper<PoiStore> {
*
*/
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}
</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>

@ -172,4 +172,15 @@
<!-- </if>-->
</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>

Loading…
Cancel
Save