|
|
@ -1,10 +1,12 @@
|
|
|
|
package com.kiisoo.ic.store.service;
|
|
|
|
package com.kiisoo.ic.store.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
import com.github.pagehelper.Page;
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
|
|
|
import com.kiisoo.aegis.common.faces.util.HttpUtil;
|
|
|
|
import com.kiisoo.ic.common.utils.ExcelUtils;
|
|
|
|
import com.kiisoo.ic.common.utils.ExcelUtils;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.common.utils.MD5FileUtil;
|
|
|
|
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
|
|
|
|
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
import com.kiisoo.ic.department.entity.DepartmentDO;
|
|
|
|
import com.kiisoo.ic.department.entity.DepartmentDO;
|
|
|
@ -12,17 +14,15 @@ import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
import com.kiisoo.ic.employee.entity.EmployeeDO;
|
|
|
|
import com.kiisoo.ic.employee.entity.EmployeeDO;
|
|
|
|
import com.kiisoo.ic.employee.entity.ImportErrorDTO;
|
|
|
|
import com.kiisoo.ic.employee.entity.ImportErrorDTO;
|
|
|
|
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
|
|
|
|
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
|
|
|
|
import com.kiisoo.ic.employee.service.EmployeeService;
|
|
|
|
import com.kiisoo.ic.employee.service.EmployeeService;
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizationalMember;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
|
|
|
|
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
|
|
|
|
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
import com.kiisoo.ic.store.entity.PrivilageCpUserStoreDO;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.entity.StoreUserDTO;
|
|
|
|
import com.kiisoo.ic.store.entity.StoreUserDTO;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
@ -35,7 +35,6 @@ import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
@ -46,11 +45,10 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
import java.io.*;
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.kiisoo.ic.employee.constant.Constants.ADD_CP_CODE_BINDED;
|
|
|
|
import static com.kiisoo.ic.employee.constant.Constants.ADD_CP_CODE_BINDED;
|
|
|
|
import static com.kiisoo.ic.store.constant.Constants.*;
|
|
|
|
import static com.kiisoo.ic.store.constant.Constants.*;
|
|
|
@ -229,6 +227,98 @@ public class StoreEmployeeService {
|
|
|
|
zipFile.delete();
|
|
|
|
zipFile.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 批量下载店铺二维码
|
|
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void downloadStoreUserCodeFromBSD(HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
//查询所有公司
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
queryWrapper.eq("status",1).eq("type",1).eq("level",2);
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(queryWrapper);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
|
|
|
String fileUrl = "门店码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
|
|
|
file.mkdir();
|
|
|
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
|
|
|
//查询客户
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> customerWrap = new QueryWrapper<>();
|
|
|
|
|
|
|
|
customerWrap.eq("status",1).eq("type",1).eq("level",3).eq("parent_id",privilageOrganizational.getId());
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> customerList = retailCompanyMapper.selectList(customerWrap);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(customerList)){
|
|
|
|
|
|
|
|
List<Long> customerIds = customerList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
//查询店铺
|
|
|
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCustomerIds(customerIds);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
|
|
|
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(poiStore.getId());
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
|
|
|
|
|
params.put("userId",cpUserId);
|
|
|
|
|
|
|
|
params.put("type",0);
|
|
|
|
|
|
|
|
params.put("storeNo",poiStore.getCode());
|
|
|
|
|
|
|
|
String get = HttpUtil.get("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=BOSIDENG" + MD5FileUtil.getMD5String(sdf.format(new Date())), params);
|
|
|
|
|
|
|
|
JSONObject saveAccountInputJSON = JSONObject.parseObject(get);
|
|
|
|
|
|
|
|
BsdShareCodeResponse bsdResponse = saveAccountInputJSON.toJavaObject(BsdShareCodeResponse.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String url = bsdResponse.getData();
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//下载图片
|
|
|
|
|
|
|
|
BufferedInputStream in = new BufferedInputStream(employeeService.getInputStream(url));
|
|
|
|
|
|
|
|
//字节流转图片对象
|
|
|
|
|
|
|
|
Image bi = ImageIO.read(in);
|
|
|
|
|
|
|
|
//构建图片流
|
|
|
|
|
|
|
|
BufferedImage tag = new BufferedImage(300, 300, BufferedImage.TYPE_INT_RGB);
|
|
|
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
|
|
|
//输出流
|
|
|
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(complayFile.getPath() +"/" +poiStore.getCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
image.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
|
|
|
int lenNew;
|
|
|
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
|
|
|
|
file.delete();
|
|
|
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
* @param response
|
|
|
|
* @param response
|
|
|
@ -311,6 +401,110 @@ public class StoreEmployeeService {
|
|
|
|
zipFile.delete();
|
|
|
|
zipFile.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void downloadStoreStaffCodeFromBSD(HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
//查询所有公司
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(null);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
|
|
|
String fileUrl = "导购码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
|
|
|
file.mkdir();
|
|
|
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> customerWrap = new QueryWrapper<>();
|
|
|
|
|
|
|
|
customerWrap.eq("status",1).eq("type",1).eq("level",3).eq("parent_id",privilageOrganizational.getId());
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> customerList = retailCompanyMapper.selectList(customerWrap);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(customerList)) {
|
|
|
|
|
|
|
|
List<Long> customerIds = customerList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
//查询店铺
|
|
|
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCustomerIds(customerIds);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
|
|
|
File storeFile = new File(complayFile.getPath()+"/"+poiStore.getName());
|
|
|
|
|
|
|
|
storeFile.mkdir();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<PoiStoreStaff> staffQr = new QueryWrapper();
|
|
|
|
|
|
|
|
staffQr.eq(DATABASE_STORE_ID_KEY,poiStore.getId());
|
|
|
|
|
|
|
|
staffQr.eq(DATABASE_TYPE_KEY,TYPE_STAFF_SELLER);
|
|
|
|
|
|
|
|
List<PoiStoreStaff> poiStoreStaffs = poiStoreStaffDOMapper.selectList(staffQr);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStoreStaffs)){
|
|
|
|
|
|
|
|
for (PoiStoreStaff poiStoreStaff:poiStoreStaffs){
|
|
|
|
|
|
|
|
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(poiStore.getId());
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
|
|
|
|
|
params.put("userId",cpUserId);
|
|
|
|
|
|
|
|
params.put("type",1);
|
|
|
|
|
|
|
|
params.put("state",poiStoreStaff.getStaffCode());
|
|
|
|
|
|
|
|
params.put("storeNo",poiStore.getCode());
|
|
|
|
|
|
|
|
String get = HttpUtil.get("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=BOSIDENG" + MD5FileUtil.getMD5String(sdf.format(new Date())), params);
|
|
|
|
|
|
|
|
JSONObject saveAccountInputJSON = JSONObject.parseObject(get);
|
|
|
|
|
|
|
|
BsdShareCodeResponse bsdResponse = saveAccountInputJSON.toJavaObject(BsdShareCodeResponse.class);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String url = bsdResponse.getData();
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//下载图片
|
|
|
|
|
|
|
|
BufferedInputStream in = new BufferedInputStream(employeeService.getInputStream(url));
|
|
|
|
|
|
|
|
//字节流转图片对象
|
|
|
|
|
|
|
|
Image bi = ImageIO.read(in);
|
|
|
|
|
|
|
|
//构建图片流
|
|
|
|
|
|
|
|
BufferedImage tag = new BufferedImage(300, 300, BufferedImage.TYPE_INT_RGB);
|
|
|
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
|
|
|
//输出流
|
|
|
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(storeFile.getPath() +"/" +poiStoreStaff.getStaffCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
|
|
|
image.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
|
|
|
int lenNew;
|
|
|
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
|
|
|
|
file.delete();
|
|
|
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 导入excel门店号
|
|
|
|
* 导入excel门店号
|
|
|
|