diff --git a/src/main/java/com/kiisoo/ic/config/WxCpConfiguration.java b/src/main/java/com/kiisoo/ic/config/WxCpConfiguration.java index c458ee4..6d2579d 100644 --- a/src/main/java/com/kiisoo/ic/config/WxCpConfiguration.java +++ b/src/main/java/com/kiisoo/ic/config/WxCpConfiguration.java @@ -44,12 +44,12 @@ public class WxCpConfiguration { @PostConstruct public void initServices() { QueryWrapper baseParams = new QueryWrapper<>(); - baseParams.eq("code","HT_CP_CORPID"); + baseParams.eq("code","CP_CORPID"); BasicConfigDO basicConfigDO = basicConfigDOMapper.selectOne(baseParams); QueryWrapper confParams = new QueryWrapper<>(); - confParams.likeRight("code","HT_CP_"); - confParams.ne("code","HT_CP_CORPID"); + confParams.likeRight("code","CP_"); + confParams.ne("code","CP_CORPID"); List confConfigDO = basicConfigDOMapper.selectList(confParams); Map> confMap = new HashMap<>(); if (CollectionUtils.isNotEmpty(confConfigDO)){ diff --git a/src/main/java/com/kiisoo/ic/store/bean/CpUserExcelDTO.java b/src/main/java/com/kiisoo/ic/store/bean/CpUserExcelDTO.java new file mode 100644 index 0000000..45e0568 --- /dev/null +++ b/src/main/java/com/kiisoo/ic/store/bean/CpUserExcelDTO.java @@ -0,0 +1,51 @@ +package com.kiisoo.ic.store.bean; + +import lombok.Data; + +@Data +public class CpUserExcelDTO { + /** + * 大区名 + */ + private String regionName; + /** + * 零售公司 + */ + private String companyName; + /** + * 零售公司编号 + */ + private String companyCode; + /** + * 店铺名 + */ + private String storeName; + /** + * 店铺编号 + */ + private String storeCode; + /** + * 企业微信号 + */ + private String cpUserId; + /** + * 企业微信号名称 + */ + private String name; + /** + * 企业微信别名 + */ + private String alias; + + public CpUserExcelDTO(){} + public CpUserExcelDTO(String regionName, String companyName, String companyCode, String storeName, String storeCode, String cpUserId, String name, String alias) { + this.regionName = regionName; + this.companyName = companyName; + this.companyCode = companyCode; + this.storeName = storeName; + this.storeCode = storeCode; + this.cpUserId = cpUserId; + this.name = name; + this.alias = alias; + } +} diff --git a/src/main/java/com/kiisoo/ic/store/controller/StoreEmployeeController.java b/src/main/java/com/kiisoo/ic/store/controller/StoreEmployeeController.java index d900853..66173db 100644 --- a/src/main/java/com/kiisoo/ic/store/controller/StoreEmployeeController.java +++ b/src/main/java/com/kiisoo/ic/store/controller/StoreEmployeeController.java @@ -93,6 +93,20 @@ public class StoreEmployeeController extends BaseController { } } + /** + * 批量下载店铺excel + * @param response + */ + @RequestMapping(value = "download/store/excel/bsd",method = RequestMethod.GET) + @ResponseBody + public void downloadStoreCpUserExcelForBSD(HttpServletResponse response) { + try { + storeEmployeeService.exportStoreExcel(response); + } catch (Exception e) { + log.error("批量下载店铺excel", e); + } + } + /** * 批量下载导购二维码 * @param response diff --git a/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java b/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java index 49fb230..8079403 100644 --- a/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java +++ b/src/main/java/com/kiisoo/ic/store/service/StoreEmployeeService.java @@ -23,6 +23,7 @@ import com.kiisoo.ic.generalize.entity.PrivilageOrganizational; import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper; import com.kiisoo.ic.generalize.service.RetailCompanyService; import com.kiisoo.ic.store.bean.BsdShareCodeResponse; +import com.kiisoo.ic.store.bean.CpUserExcelDTO; import com.kiisoo.ic.store.bean.PoiStoreStaffDTO; import com.kiisoo.ic.store.entity.PoiStore; import com.kiisoo.ic.store.entity.PoiStoreStaff; @@ -33,10 +34,13 @@ import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper; import com.kiisoo.ic.utils.ZipUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.poi.hssf.usermodel.HSSFCellStyle; import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -368,6 +372,130 @@ public class StoreEmployeeService { } } + /** + * 批量下载店铺二维码 + * + * @param response + */ + public void exportStoreExcel(HttpServletResponse response) throws Exception { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + List results = new ArrayList<>(); + + //查询大区 + QueryWrapper regionWrapper = new QueryWrapper<>(); + regionWrapper.eq("status", 1).eq("type", 2).eq("level", 1); + List regions = retailCompanyMapper.selectList(regionWrapper); + if (CollectionUtils.isNotEmpty(regions)){ + for (PrivilageOrganizational region:regions){ + if (region == null || region.getId() == null) { + continue; + } + //查询所有公司 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("status", 1).eq("type", 2).eq("level", 2).eq("parent_id",region.getId()); + List privilageOrganizationals = retailCompanyMapper.selectList(queryWrapper); + if (CollectionUtils.isNotEmpty(privilageOrganizationals)) { + //遍历零售公司 + for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) { + if (privilageOrganizational == null || privilageOrganizational.getId() == null) { + continue; + } + //查询客户 + QueryWrapper customerWrap = new QueryWrapper<>(); + customerWrap.eq("status", 1).eq("type", 2).eq("level", 3).eq("parent_id", privilageOrganizational.getId()); + List customerList = retailCompanyMapper.selectList(customerWrap); + if (CollectionUtils.isNotEmpty(customerList)) { + List customerIds = customerList.stream().map(i -> i.getId()).collect(Collectors.toList()); + //查询店铺 + List poiStores = poiStoreDOMapper.selectShopByCustomerIds(customerIds); + if (CollectionUtils.isNotEmpty(poiStores)) { + //遍历店铺查询门店码url + for (PoiStore poiStore : poiStores) { + String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(poiStore.getId()); + if (StringUtils.isBlank(cpUserId)) { + continue; + } + QueryWrapper userQw = new QueryWrapper<>(); + userQw.eq("cp_user_id",cpUserId).last("limit 1"); + PrivilageCpUserDO privilageCpUserDO = privilageCpUserDOMapper.selectOne(userQw); + if (privilageCpUserDO == null) { + continue; + } + CpUserExcelDTO excelDTO = new CpUserExcelDTO(region.getName(),privilageOrganizational.getName(), + privilageOrganizational.getCode(),poiStore.getName(),poiStore.getCode(), + privilageCpUserDO.getCpUserId(),privilageCpUserDO.getName(),privilageCpUserDO.getAlias()); + results.add(excelDTO); + } + } + } + } + } + } + } + + if (CollectionUtils.isNotEmpty(results)){ + createStoreUserExcel(results,response); + } + + } + + public void createStoreUserExcel(List results,HttpServletResponse response) throws IOException { + String[] headNames = new String[]{"序号","大区名","零售公司","零售公司编号","店铺名","店铺编号"," 企业微信号","企业微信号名称","企业微信号别名"}; + 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 < results.size(); i++) { + + //创造行 + Row row = hssfSheet.createRow(isAdd++); + + CpUserExcelDTO cpUserExcelDTO = results.get(i); + Cell orderCell = row.createCell(0); + orderCell.setCellValue(i + 1 +""); + Cell reginCell = row.createCell(1); + reginCell.setCellValue(cpUserExcelDTO.getRegionName()); + Cell companyNameCell = row.createCell(2); + companyNameCell.setCellValue(cpUserExcelDTO.getCompanyName()); + Cell companyCodeCell = row.createCell(3); + companyCodeCell.setCellValue(cpUserExcelDTO.getCompanyCode()); + Cell storeNameCell = row.createCell(4); + storeNameCell.setCellValue(cpUserExcelDTO.getStoreName()); + Cell storeCodeCell = row.createCell(5); + storeCodeCell.setCellValue(cpUserExcelDTO.getStoreCode()); + Cell cpUserIdCell = row.createCell(6); + cpUserIdCell.setCellValue(cpUserExcelDTO.getCpUserId()); + Cell nameCell = row.createCell(7); + nameCell.setCellValue(cpUserExcelDTO.getName()); + Cell aliasCell = row.createCell(8); + aliasCell.setCellValue(cpUserExcelDTO.getAlias()); + } + OutputStream output = response.getOutputStream(); + response.reset(); + response.setHeader("Content-disposition", "attachment; filename=store.xls"); + response.setContentType("application/msexcel"); + ws.write(output); + } + /** * 批量下载店铺导购吗 * diff --git a/src/main/java/com/kiisoo/ic/webappmy/controller/WebAppMyController.java b/src/main/java/com/kiisoo/ic/webappmy/controller/WebAppMyController.java index b5b58d3..32bceaa 100644 --- a/src/main/java/com/kiisoo/ic/webappmy/controller/WebAppMyController.java +++ b/src/main/java/com/kiisoo/ic/webappmy/controller/WebAppMyController.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_SELLER; import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_STORE; /** @@ -114,7 +115,7 @@ public class WebAppMyController extends BaseController { if (StringUtils.isBlank(img)){ Long storeId = poiStoreStaffs.get(0).getStoreId(); String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(storeId); - img = storeEmployeeService.getQrCodeFromBSD(cpUserId,BSD_REQ_QRCODE_TYPE_STORE,"0",poiStoreStaffs.get(0).getStoreCode()); + img = storeEmployeeService.getQrCodeFromBSD(cpUserId,BSD_REQ_QRCODE_TYPE_SELLER,poiStoreStaffs.get(0).getStaffCode(),poiStoreStaffs.get(0).getStoreCode()); PoiStoreStaff update = new PoiStoreStaff(); update.setId(poiStoreStaffs.get(0).getId()); update.setEpWechatQrCode(img);