|
|
|
@ -8,7 +8,10 @@ import com.kiisoo.ic.common.utils.MD5FileUtil;
|
|
|
|
|
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
|
|
|
|
|
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
|
|
|
|
|
import com.kiisoo.ic.config.WxCpConfiguration;
|
|
|
|
|
import com.kiisoo.ic.customer.entity.OpCustomer;
|
|
|
|
|
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
|
import com.kiisoo.ic.customer.service.CustomerViewService;
|
|
|
|
|
import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
@ -19,6 +22,7 @@ import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.PoiCustomerContactDataStatMapper;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
|
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
|
|
|
|
|
import com.kiisoo.ic.store.bean.CustomerDistinctDTO;
|
|
|
|
|
import com.kiisoo.ic.store.constant.Constants;
|
|
|
|
|
import com.kiisoo.ic.store.entity.*;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
@ -41,6 +45,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
@ -67,6 +72,18 @@ public class StorePromotionDataService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private StorePromotionDataDOMapper storePromotionDataDOMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 门店数据mapper
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 门店数据mapper
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpCustomerDOMapper opCustomerDOMapper;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 门店数据mapper
|
|
|
|
|
*/
|
|
|
|
@ -591,4 +608,89 @@ public class StorePromotionDataService {
|
|
|
|
|
}
|
|
|
|
|
return storePromotionDataDO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void distinctCustomer(HttpServletResponse response) throws IOException {
|
|
|
|
|
List<Map<String,Object>> customerIds = storePromotionDataDOMapper.selectDistinctCustomer();
|
|
|
|
|
List<CustomerDistinctDTO> customerDistinctDTOS = new ArrayList<>();
|
|
|
|
|
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((Integer) 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());
|
|
|
|
|
|
|
|
|
|
customerDistinctDTO.setCompanyName(company.getName());
|
|
|
|
|
customerDistinctDTO.setCompanyCode(company.getCode());
|
|
|
|
|
}
|
|
|
|
|
customerDistinctDTO.setStoreId(opSellerCustomerRelation.getStoreId());
|
|
|
|
|
customerDistinctDTO.setCustomerId(opSellerCustomerRelation.getCustomerId());
|
|
|
|
|
customerDistinctDTO.setCustomerName(customer.getName());
|
|
|
|
|
customerDistinctDTO.setCustomerUserId(customer.getExternalUserid());
|
|
|
|
|
customerDistinctDTOS.add(customerDistinctDTO);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
customerDistinctDTOS.sort(new Comparator<CustomerDistinctDTO>() {
|
|
|
|
|
@Override
|
|
|
|
|
public int compare(CustomerDistinctDTO o1, CustomerDistinctDTO o2) {
|
|
|
|
|
return o1.getStoreId().compareTo(o2.getStoreId());
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
String[] headNames = new String[]{"零售公司编号", "零售公司","店铺名", "店铺编号", "客户名称", "客户id", "添加店铺总数"};
|
|
|
|
|
HSSFWorkbook ws = new HSSFWorkbook();
|
|
|
|
|
Sheet hssfSheet = ws.createSheet("推广管理");
|
|
|
|
|
HSSFCellStyle cellStyle = ws.createCellStyle();
|
|
|
|
|
cellStyle.setWrapText(true);//设置自动换行
|
|
|
|
|
int isAdd = 0;
|
|
|
|
|
//设置列名
|
|
|
|
|
if (null != headNames && headNames.length > 0) {
|
|
|
|
|
|
|
|
|
|
Row row = hssfSheet.createRow(isAdd++);
|
|
|
|
|
for (int i = 0; i < headNames.length; i++) {
|
|
|
|
|
|
|
|
|
|
String name = headNames[i];
|
|
|
|
|
Cell cell = row.createCell(i);
|
|
|
|
|
cell.setCellValue(name);
|
|
|
|
|
}
|
|
|
|
|
isAdd++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < customerDistinctDTOS.size(); i++) {
|
|
|
|
|
//创造行
|
|
|
|
|
Row row = hssfSheet.createRow(isAdd++);
|
|
|
|
|
CustomerDistinctDTO customerDistinctDTO = customerDistinctDTOS.get(i);
|
|
|
|
|
|
|
|
|
|
Cell cpUserIdCell = row.createCell(0);
|
|
|
|
|
cpUserIdCell.setCellValue(customerDistinctDTO.getCompanyCode());
|
|
|
|
|
Cell storeCodeCell = row.createCell(1);
|
|
|
|
|
storeCodeCell.setCellValue(customerDistinctDTO.getCompanyName());
|
|
|
|
|
|
|
|
|
|
Cell reginCell = row.createCell(2);
|
|
|
|
|
reginCell.setCellValue(customerDistinctDTO.getStoreName());
|
|
|
|
|
Cell companyNameCell = row.createCell(3);
|
|
|
|
|
companyNameCell.setCellValue(customerDistinctDTO.getStoreCode());
|
|
|
|
|
|
|
|
|
|
Cell companyCodeCell = row.createCell(4);
|
|
|
|
|
companyCodeCell.setCellValue(customerDistinctDTO.getCustomerName());
|
|
|
|
|
Cell storeNameCell = row.createCell(5);
|
|
|
|
|
storeNameCell.setCellValue(customerDistinctDTO.getCustomerUserId());;
|
|
|
|
|
Cell nameCell = row.createCell(6);
|
|
|
|
|
nameCell.setCellValue(customerDistinctDTO.getCount());
|
|
|
|
|
}
|
|
|
|
|
OutputStream output = response.getOutputStream();
|
|
|
|
|
response.setHeader("Content-disposition", "attachment; filename=store.xls");
|
|
|
|
|
response.setContentType("application/vnd.ms-excel");
|
|
|
|
|
ws.write(output);
|
|
|
|
|
ws.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|