|
|
|
@ -15,6 +15,7 @@ import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
|
import com.kiisoo.ic.employee.entity.EmployeeDO;
|
|
|
|
|
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.service.EmployeeService;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
@ -94,99 +95,139 @@ public class StoreEmployeeService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private CustomerViewService customerViewService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询门店号
|
|
|
|
|
* @param storeId 门店id
|
|
|
|
|
*
|
|
|
|
|
* @param storeId 门店id
|
|
|
|
|
* @param regionId 区域id
|
|
|
|
|
*/
|
|
|
|
|
public PageInfo<StoreUserDTO> listStoreUser(Long userId ,Long storeId, Long bigRegionId,Long companyId, Integer pageNum, Integer pageSize,String code) {
|
|
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
|
|
|
public PageInfo<StoreUserDTO> listStoreUser(Long userId, Long storeId, Long bigRegionId, Long companyId, Integer pageNum, Integer pageSize, String code) throws Exception {
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
List<PoiStore> poiStores = null;
|
|
|
|
|
List<Long> shopIds = new ArrayList<>();
|
|
|
|
|
if (storeId != null){
|
|
|
|
|
if (storeId != null) {
|
|
|
|
|
shopIds.add(storeId);
|
|
|
|
|
}else if(StringUtils.isNotBlank(code)){
|
|
|
|
|
List<PoiStore> store = poiStoreDOMapper.selectShopByNameOrCode(code);
|
|
|
|
|
} else if (StringUtils.isNotBlank(code)) {
|
|
|
|
|
List<PoiStore> store = poiStoreDOMapper.selectShopByNameOrCode(code);
|
|
|
|
|
shopIds = store.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
|
|
List<Long> userAllShops = privilageDomainService.listUserDatePermission(userId);
|
|
|
|
|
shopIds.retainAll(userAllShops);
|
|
|
|
|
}else if(companyId != null){
|
|
|
|
|
} else if (companyId != null) {
|
|
|
|
|
shopIds = new ArrayList<>(customerViewService.getCompanyShop(companyId, userId));
|
|
|
|
|
List<Long> userAllShops = privilageDomainService.listUserDatePermission(userId);
|
|
|
|
|
shopIds.retainAll(userAllShops);
|
|
|
|
|
}else if(bigRegionId != null){
|
|
|
|
|
} else if (bigRegionId != null) {
|
|
|
|
|
shopIds = new ArrayList<>(customerViewService.getCompanyShop(bigRegionId, userId));
|
|
|
|
|
List<Long> userAllShops = privilageDomainService.listUserDatePermission(userId);
|
|
|
|
|
shopIds.retainAll(userAllShops);
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
//查询用户权限店铺
|
|
|
|
|
shopIds = new ArrayList<>(privilageDomainService.listUserDatePermission(userId));
|
|
|
|
|
}
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
|
List<StoreUserDTO> cpUserStoreDO = privilageCpUserStoreDOMapper.selectCpUserByShops(shopIds);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(cpUserStoreDO)){
|
|
|
|
|
int orderNum = (pageNum -1) * pageSize;
|
|
|
|
|
for(StoreUserDTO cpUserStore : cpUserStoreDO) {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(cpUserStoreDO)) {
|
|
|
|
|
int orderNum = (pageNum - 1) * pageSize;
|
|
|
|
|
for (StoreUserDTO cpUserStore : cpUserStoreDO) {
|
|
|
|
|
//设置序号
|
|
|
|
|
cpUserStore.setOrderNum(++orderNum);
|
|
|
|
|
//查询店铺绑定的企业微信
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(cpUserStore.getId());
|
|
|
|
|
if (null != poiStore){
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectById(cpUserStore.getId());
|
|
|
|
|
if (null != poiStore) {
|
|
|
|
|
cpUserStore.setName(poiStore.getName());
|
|
|
|
|
cpUserStore.setCode(poiStore.getCode());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String qrCodeAction = cpUserStore.getQrCodeAction();
|
|
|
|
|
if (StringUtils.isBlank(qrCodeAction)){
|
|
|
|
|
qrCodeAction = getQrCodeFromBSD(cpUserStore.getCpUserId(),BSD_REQ_QRCODE_TYPE_STORE,"0",cpUserStore.getCode());
|
|
|
|
|
cpUserStore.setQrCodeAction(qrCodeAction);
|
|
|
|
|
PrivilageCpUserDO update = new PrivilageCpUserDO();
|
|
|
|
|
update.setId(cpUserStore.getUserId());
|
|
|
|
|
update.setQrCode(qrCodeAction);
|
|
|
|
|
privilageCpUserDOMapper.updateById(update);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//查询导购数目
|
|
|
|
|
List<Long> shops = Arrays.asList(cpUserStore.getId());
|
|
|
|
|
List<PoiStoreStaffDTO> sellerList = poiStoreStaffDOMapper.selectSellersByShopIds(shops);
|
|
|
|
|
int staffNum = 0;
|
|
|
|
|
if (null != sellerList && sellerList.size() > 0){
|
|
|
|
|
List<PoiStoreStaffDTO> sellerList = poiStoreStaffDOMapper.selectSellersByShopIds(shops);
|
|
|
|
|
int staffNum = 0;
|
|
|
|
|
if (null != sellerList && sellerList.size() > 0) {
|
|
|
|
|
staffNum = sellerList.size();
|
|
|
|
|
}
|
|
|
|
|
cpUserStore.setStaffNum(staffNum);
|
|
|
|
|
//客户数
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper2 = new QueryWrapper<>();
|
|
|
|
|
wrapper2.eq("store_id",cpUserStore.getId());
|
|
|
|
|
wrapper2.eq("store_id", cpUserStore.getId());
|
|
|
|
|
List<OpSellerCustomerRelation> opRelations = opSellerCustomerRelationDOMapper.selectList(wrapper2);
|
|
|
|
|
long count = opRelations.stream().map(OpSellerCustomerRelation::getCustomerId).distinct().count();
|
|
|
|
|
cpUserStore.setCustomerNum((int)count);
|
|
|
|
|
cpUserStore.setCustomerNum((int) count);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return new PageInfo<>(cpUserStoreDO) ;
|
|
|
|
|
return new PageInfo<>(cpUserStoreDO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取波司登二维码
|
|
|
|
|
* @param cpUserId
|
|
|
|
|
* @param type
|
|
|
|
|
* @param state
|
|
|
|
|
* @param storeNo
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public String getQrCodeFromBSD(String cpUserId,String type,String state,String storeNo) throws Exception {
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
|
|
params.put("userId", cpUserId);
|
|
|
|
|
params.put("type", type);
|
|
|
|
|
params.put("state", state);
|
|
|
|
|
params.put("storeNo", storeNo);
|
|
|
|
|
String get = HttpUtil.post("http://vtest.bsd.cn/BSD_WXAPP/qyWechat/getShareQRcode?token=" + MD5FileUtil.getMD5String("BOSIDENG"+sdf.format(new Date())), params);
|
|
|
|
|
JSONObject qrCodeJson = JSONObject.parseObject(get);
|
|
|
|
|
BsdShareCodeResponse bsdResponse = qrCodeJson.toJavaObject(BsdShareCodeResponse.class);
|
|
|
|
|
if (bsdResponse.getSuccess()){
|
|
|
|
|
return bsdResponse.getResultCode();
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量下载店铺二维码
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
*/
|
|
|
|
|
public void downloadStoreUserCode(HttpServletResponse response) throws IOException {
|
|
|
|
|
//查询所有公司
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(null);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)) {
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
String fileUrl = "门店码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
String fileUrl = "门店码-" + UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
String strZipName = "store_qrCode_" + fileUrl + ".zip";
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
File complayFile = new File(file.getPath() + "/" + privilageOrganizational.getName());
|
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
//查询店铺
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(privilageOrganizational.getId());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
String url = poiStoreDOMapper.selectStoreQrCode(poiStore.getId());
|
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
|
if (StringUtils.isBlank(url)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//下载图片
|
|
|
|
@ -198,7 +239,7 @@ public class StoreEmployeeService {
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
//输出流
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(complayFile.getPath() +"/" +poiStore.getCode() + ".png"));
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(complayFile.getPath() + "/" + poiStore.getCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
@ -209,7 +250,7 @@ public class StoreEmployeeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
@ -225,59 +266,61 @@ public class StoreEmployeeService {
|
|
|
|
|
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);
|
|
|
|
|
queryWrapper.eq("status", 1).eq("type", 1).eq("level", 2);
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(queryWrapper);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)) {
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
String fileUrl = "门店码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
String fileUrl = "门店码-" + UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
String strZipName = "store_qrCode_" + fileUrl + ".zip";
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
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());
|
|
|
|
|
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)){
|
|
|
|
|
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)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(poiStore.getId());
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)){
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
|
|
params.put("userId",cpUserId);
|
|
|
|
|
params.put("type",0);
|
|
|
|
|
params.put("storeNo",poiStore.getCode());
|
|
|
|
|
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)){
|
|
|
|
|
if (StringUtils.isBlank(url)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//下载图片
|
|
|
|
@ -289,7 +332,7 @@ public class StoreEmployeeService {
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
//输出流
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(complayFile.getPath() +"/" +poiStore.getCode() + ".png"));
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(complayFile.getPath() + "/" + poiStore.getCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
@ -301,7 +344,7 @@ public class StoreEmployeeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
@ -317,48 +360,50 @@ public class StoreEmployeeService {
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
*/
|
|
|
|
|
public void downloadStoreStaffCode(HttpServletResponse response) throws IOException {
|
|
|
|
|
//查询所有公司
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(null);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)) {
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
String fileUrl = "导购码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
String fileUrl = "导购码-" + UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
String strZipName = "store_qrCode_" + fileUrl + ".zip";
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
File complayFile = new File(file.getPath() + "/" + privilageOrganizational.getName());
|
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
//查询店铺
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(privilageOrganizational.getId());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File storeFile = new File(complayFile.getPath()+"/"+poiStore.getName());
|
|
|
|
|
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);
|
|
|
|
|
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){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStoreStaffs)) {
|
|
|
|
|
for (PoiStoreStaff poiStoreStaff : poiStoreStaffs) {
|
|
|
|
|
String url = poiStoreStaff.getEpWechatQrCode();
|
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
|
if (StringUtils.isBlank(url)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//下载图片
|
|
|
|
@ -370,7 +415,7 @@ public class StoreEmployeeService {
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
//输出流
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(storeFile.getPath() +"/" +poiStoreStaff.getStaffCode() + ".png"));
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(storeFile.getPath() + "/" + poiStoreStaff.getStaffCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
@ -383,7 +428,7 @@ public class StoreEmployeeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
@ -399,67 +444,69 @@ public class StoreEmployeeService {
|
|
|
|
|
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)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)) {
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
String fileUrl = "导购码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
String fileUrl = "导购码-" + UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
String strZipName = "store_qrCode_" + fileUrl + ".zip";
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
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());
|
|
|
|
|
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)){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File storeFile = new File(complayFile.getPath()+"/"+poiStore.getName());
|
|
|
|
|
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);
|
|
|
|
|
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){
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStoreStaffs)) {
|
|
|
|
|
for (PoiStoreStaff poiStoreStaff : poiStoreStaffs) {
|
|
|
|
|
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(poiStore.getId());
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)){
|
|
|
|
|
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());
|
|
|
|
|
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)){
|
|
|
|
|
if (StringUtils.isBlank(url)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -472,7 +519,7 @@ public class StoreEmployeeService {
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
//输出流
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(storeFile.getPath() +"/" +poiStoreStaff.getStaffCode() + ".png"));
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(storeFile.getPath() + "/" + poiStoreStaff.getStaffCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
@ -487,7 +534,7 @@ public class StoreEmployeeService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
@ -506,6 +553,7 @@ public class StoreEmployeeService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 导入excel门店号
|
|
|
|
|
*
|
|
|
|
|
* @param file excel文件
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
@ -536,7 +584,7 @@ public class StoreEmployeeService {
|
|
|
|
|
if (dataRow == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
addRowInfo(dataRow,results,r);
|
|
|
|
|
addRowInfo(dataRow, results, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -545,39 +593,40 @@ public class StoreEmployeeService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Excel导入门店号-添加行信息
|
|
|
|
|
*
|
|
|
|
|
* @param dataRow 行对象
|
|
|
|
|
* @param results 错误信息集合
|
|
|
|
|
* @param row 行数
|
|
|
|
|
* @param row 行数
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
private void addRowInfo(Row dataRow,List<ImportErrorDTO> results,Integer row) throws Exception {
|
|
|
|
|
private void addRowInfo(Row dataRow, List<ImportErrorDTO> results, Integer row) throws Exception {
|
|
|
|
|
//初始化导购对象
|
|
|
|
|
EmployeeDO employeeDO = new EmployeeDO();
|
|
|
|
|
//获取店铺名和店铺code
|
|
|
|
|
String shopName = dataRow.getCell(0).getStringCellValue();
|
|
|
|
|
if (StringUtils.isBlank(shopName)){
|
|
|
|
|
getReason(row,"未填写店铺名",results);
|
|
|
|
|
if (StringUtils.isBlank(shopName)) {
|
|
|
|
|
getReason(row, "未填写店铺名", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
String shopCode = dataRow.getCell(1).getStringCellValue();
|
|
|
|
|
if (StringUtils.isBlank(shopCode)){
|
|
|
|
|
getReason(row,"未填写店铺Code",results);
|
|
|
|
|
if (StringUtils.isBlank(shopCode)) {
|
|
|
|
|
getReason(row, "未填写店铺Code", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//查询店铺信息
|
|
|
|
|
QueryWrapper<PoiStore> storeParams = new QueryWrapper<>();
|
|
|
|
|
storeParams.eq(DATABASE_NAME_KEY,shopName);
|
|
|
|
|
storeParams.eq(DATABASE_CODE_KEY,shopCode);
|
|
|
|
|
storeParams.eq(DATABASE_NAME_KEY, shopName);
|
|
|
|
|
storeParams.eq(DATABASE_CODE_KEY, shopCode);
|
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectOne(storeParams);
|
|
|
|
|
if (poiStore == null){
|
|
|
|
|
getReason(row,"未找到店铺",results);
|
|
|
|
|
if (poiStore == null) {
|
|
|
|
|
getReason(row, "未找到店铺", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
employeeDO.setStoreId(poiStore.getId());
|
|
|
|
|
//获取企业微信账号(user_id)
|
|
|
|
|
String cpUserId = dataRow.getCell(2).getStringCellValue();
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)){
|
|
|
|
|
getReason(row,"未填写账号",results);
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)) {
|
|
|
|
|
getReason(row, "未填写账号", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
employeeDO.setUserId(cpUserId);
|
|
|
|
@ -588,15 +637,15 @@ public class StoreEmployeeService {
|
|
|
|
|
|
|
|
|
|
//获取部门信息
|
|
|
|
|
String departmentName = dataRow.getCell(4).getStringCellValue();
|
|
|
|
|
if (StringUtils.isBlank(departmentName)){
|
|
|
|
|
getReason(row,"未填写部门",results);
|
|
|
|
|
if (StringUtils.isBlank(departmentName)) {
|
|
|
|
|
getReason(row, "未填写部门", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QueryWrapper<DepartmentDO> depParams = new QueryWrapper<DepartmentDO>();
|
|
|
|
|
depParams.eq(DATABASE_NAME_KEY,departmentName);
|
|
|
|
|
depParams.eq(DATABASE_NAME_KEY, departmentName);
|
|
|
|
|
DepartmentDO departmentDO = departmentDOMapper.selectOne(depParams);
|
|
|
|
|
if (departmentDO == null){
|
|
|
|
|
getReason(row,"未找到部门",results);
|
|
|
|
|
if (departmentDO == null) {
|
|
|
|
|
getReason(row, "未找到部门", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Long[] depIds = new Long[1];
|
|
|
|
@ -604,29 +653,30 @@ public class StoreEmployeeService {
|
|
|
|
|
employeeDO.setDepartIds(depIds);
|
|
|
|
|
|
|
|
|
|
String mobile = dataRow.getCell(5).getStringCellValue();
|
|
|
|
|
if (StringUtils.isBlank(mobile)){
|
|
|
|
|
getReason(row,"未填写手机号",results);
|
|
|
|
|
if (StringUtils.isBlank(mobile)) {
|
|
|
|
|
getReason(row, "未填写手机号", results);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
employeeDO.setMobile(mobile);
|
|
|
|
|
|
|
|
|
|
String returnCode = employeeService.addUser(employeeDO);
|
|
|
|
|
if (returnCode.contains(ADD_CP_CODE_BINDED)){
|
|
|
|
|
if (returnCode.contains(ADD_CP_CODE_BINDED)) {
|
|
|
|
|
String[] split = returnCode.split("&");
|
|
|
|
|
getReason(row,"该账号已绑定【"+ split[1] +"】店铺",results);
|
|
|
|
|
getReason(row, "该账号已绑定【" + split[1] + "】店铺", results);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加错误原因
|
|
|
|
|
* @param row 行数
|
|
|
|
|
* @param reason 原因
|
|
|
|
|
*
|
|
|
|
|
* @param row 行数
|
|
|
|
|
* @param reason 原因
|
|
|
|
|
* @param results 错误集合
|
|
|
|
|
*/
|
|
|
|
|
private void getReason(Integer row,String reason,List<ImportErrorDTO> results){
|
|
|
|
|
private void getReason(Integer row, String reason, List<ImportErrorDTO> results) {
|
|
|
|
|
ImportErrorDTO importErrorDTO = new ImportErrorDTO();
|
|
|
|
|
importErrorDTO.setRow(row);
|
|
|
|
|
reason = "第"+ row + "行导入失败,原因:"+reason;
|
|
|
|
|
reason = "第" + row + "行导入失败,原因:" + reason;
|
|
|
|
|
importErrorDTO.setReason(reason);
|
|
|
|
|
results.add(importErrorDTO);
|
|
|
|
|
}
|
|
|
|
|