|
|
|
@ -612,30 +612,38 @@ public class StorePromotionDataService {
|
|
|
|
|
public void distinctCustomer(HttpServletResponse response) throws IOException {
|
|
|
|
|
List<Map<String,Object>> customerIds = storePromotionDataDOMapper.selectDistinctCustomer();
|
|
|
|
|
List<CustomerDistinctDTO> customerDistinctDTOS = new ArrayList<>();
|
|
|
|
|
Map<Long,PrivilageOrganizational> storeCompanyMap = new HashMap<>();
|
|
|
|
|
customerIds.forEach(customerId ->{
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> relationQw = new QueryWrapper<>();
|
|
|
|
|
relationQw.eq("customer_id",customerId.get("customerId")).ne("type",3);
|
|
|
|
|
List<OpSellerCustomerRelation> opSellerCustomerRelations = opSellerCustomerRelationDOMapper.selectList(relationQw);
|
|
|
|
|
OpCustomer customer = opCustomerDOMapper.selectById((Serializable) customerId.get("customerId"));
|
|
|
|
|
opSellerCustomerRelations.forEach(opSellerCustomerRelation -> {
|
|
|
|
|
CustomerDistinctDTO customerDistinctDTO = new CustomerDistinctDTO();
|
|
|
|
|
customerDistinctDTO.setCount((Long) customerId.get("count"));
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(opSellerCustomerRelation.getStoreId());
|
|
|
|
|
customerDistinctDTO.setStoreName(poiStore.getName());
|
|
|
|
|
customerDistinctDTO.setStoreCode(poiStore.getCode());
|
|
|
|
|
Long orgCustomerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(poiStore.getId());
|
|
|
|
|
|
|
|
|
|
if (orgCustomerId != null) {
|
|
|
|
|
PrivilageOrganizational orgCustomer = retailCompanyMapper.selectById(orgCustomerId);
|
|
|
|
|
PrivilageOrganizational company = retailCompanyMapper.selectById(orgCustomer.getParentId());
|
|
|
|
|
|
|
|
|
|
if (storeCompanyMap.get(poiStore.getId())!=null){
|
|
|
|
|
PrivilageOrganizational company = storeCompanyMap.get(poiStore.getId());
|
|
|
|
|
customerDistinctDTO.setCompanyName(company.getName());
|
|
|
|
|
customerDistinctDTO.setCompanyCode(company.getCode());
|
|
|
|
|
}else{
|
|
|
|
|
Long orgCustomerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(poiStore.getId());
|
|
|
|
|
|
|
|
|
|
if (orgCustomerId != null) {
|
|
|
|
|
PrivilageOrganizational orgCustomer = retailCompanyMapper.selectById(orgCustomerId);
|
|
|
|
|
PrivilageOrganizational company = retailCompanyMapper.selectById(orgCustomer.getParentId());
|
|
|
|
|
|
|
|
|
|
customerDistinctDTO.setCompanyName(company.getName());
|
|
|
|
|
customerDistinctDTO.setCompanyCode(company.getCode());
|
|
|
|
|
storeCompanyMap.put(poiStore.getId(),company);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
customerDistinctDTO.setStoreId(opSellerCustomerRelation.getStoreId());
|
|
|
|
|
customerDistinctDTO.setCustomerId(opSellerCustomerRelation.getCustomerId());
|
|
|
|
|
customerDistinctDTO.setCustomerName(customer.getName());
|
|
|
|
|
customerDistinctDTO.setCustomerUserId(customer.getExternalUserid());
|
|
|
|
|
customerDistinctDTO.setCustomerName((String)customerId.get("customerName"));
|
|
|
|
|
customerDistinctDTO.setCustomerUserId((String)customerId.get("customerUserId"));
|
|
|
|
|
customerDistinctDTOS.add(customerDistinctDTO);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|