大屏接口

dev_0531
yechenhao 5 years ago
parent bda3ac0fac
commit 9af471035a

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

@ -411,13 +411,13 @@
</select> </select>
<select id="selectDistinctCustomer" resultType="Map"> <select id="selectDistinctCustomer" resultType="Map">
SELECT SELECT
customer_id as customerId,count( store_id ) as count t1.customer_id as customerId,t2.name as customerName,t2.external_userid as customerUserId,t1.count( store_id ) as count
FROM FROM
op_seller_customer_relation op_seller_customer_relation t1 left join op_customer t2 on t1.customer_id = t2.id
GROUP BY GROUP BY
customer_id t1.customer_id
HAVING HAVING
count( store_id ) > 1; count( t1.store_id ) > 1;
</select> </select>

Loading…
Cancel
Save