|
|
|
@ -5,14 +5,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.kiisoo.aegis.common.faces.util.HttpUtil;
|
|
|
|
|
import com.kiisoo.ic.common.KiisooException;
|
|
|
|
|
import com.kiisoo.ic.common.utils.ExcelUtils;
|
|
|
|
|
import com.kiisoo.ic.common.utils.MD5FileUtil;
|
|
|
|
|
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
|
|
|
|
|
import com.kiisoo.ic.constants.Constants;
|
|
|
|
|
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
|
import com.kiisoo.ic.customer.service.CustomerViewService;
|
|
|
|
|
import com.kiisoo.ic.department.entity.DepartmentDO;
|
|
|
|
|
import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.entity.PrivilageDomainDO;
|
|
|
|
|
import com.kiisoo.ic.domain.entity.PrivilageDomainEntityDO;
|
|
|
|
|
import com.kiisoo.ic.domain.mapper.PrivilageDomainDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper;
|
|
|
|
|
import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
|
import com.kiisoo.ic.employee.entity.EmployeeDO;
|
|
|
|
@ -21,11 +26,14 @@ 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;
|
|
|
|
|
import com.kiisoo.ic.generalize.entity.PrivilageOrganizationalDomain;
|
|
|
|
|
import com.kiisoo.ic.generalize.mapper.PrivilageOrganizationalDomainMapper;
|
|
|
|
|
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.bean.PoiStoreVO;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
|
import com.kiisoo.ic.store.entity.StoreUserDTO;
|
|
|
|
@ -35,6 +43,7 @@ import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
|
import com.kiisoo.ic.utils.ZipUtils;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
@ -48,6 +57,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
@ -103,13 +113,27 @@ public class StoreEmployeeService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组织表
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private RetailCompanyService retailCompanyService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 客户数据概览service
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private CustomerViewService customerViewService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 组织和域的关系表
|
|
|
|
|
*/
|
|
|
|
|
@Autowired
|
|
|
|
|
private PrivilageOrganizationalDomainMapper privilageOrganizationalDomainMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PrivilageDomainDOMapper privilageDomainDOMapper;
|
|
|
|
|
|
|
|
|
|
@Value("${bsd.qrCode}")
|
|
|
|
|
private String qrCodeBsdUrl;
|
|
|
|
|
|
|
|
|
@ -924,4 +948,121 @@ public class StoreEmployeeService {
|
|
|
|
|
}
|
|
|
|
|
return bsdResponse.getSuccess();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加组织
|
|
|
|
|
* @param name 名称
|
|
|
|
|
* @param code 编码
|
|
|
|
|
* @author dexiang.jiang
|
|
|
|
|
* @date 2020/05/20 14:57
|
|
|
|
|
*/
|
|
|
|
|
public boolean addOrganizational(String name, String code, Long parentId, Long level) throws KiisooException {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("name", name);
|
|
|
|
|
map.put("code", code);
|
|
|
|
|
map.put("level", level);
|
|
|
|
|
List<PrivilageOrganizational> list = retailCompanyMapper.selectByMap(map);
|
|
|
|
|
if(CollectionUtils.isNotEmpty(list) && list.size() > 0){
|
|
|
|
|
throw new KiisooException(Constants.MSG_ORGANIZATIONAL_HAS, Constants.CODE_ORGANIZATIONAL_HAS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrivilageOrganizational entity = new PrivilageOrganizational();
|
|
|
|
|
entity.setName(name);
|
|
|
|
|
entity.setCode(code);
|
|
|
|
|
entity.setParentId(parentId);
|
|
|
|
|
entity.setLevel(level);
|
|
|
|
|
entity.setStatus(1L);
|
|
|
|
|
entity.setType(1L);
|
|
|
|
|
entity.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
entity.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
entity.setCreateTime(new Date());
|
|
|
|
|
entity.setUpdateTime(new Date());
|
|
|
|
|
int b = retailCompanyMapper.insert(entity);
|
|
|
|
|
|
|
|
|
|
if(level == 3){
|
|
|
|
|
//添加客户多了2步骤
|
|
|
|
|
Map<String, Object> domainEntityMap = new HashMap<>();
|
|
|
|
|
domainEntityMap.put("name", name);
|
|
|
|
|
List<PrivilageDomainDO> domainList = privilageDomainDOMapper.selectByMap(domainEntityMap);
|
|
|
|
|
if(domainList.size() > 1){
|
|
|
|
|
throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS);
|
|
|
|
|
}
|
|
|
|
|
//添加域
|
|
|
|
|
PrivilageDomainDO domainEntity = new PrivilageDomainDO();
|
|
|
|
|
domainEntity.setName(name);
|
|
|
|
|
domainEntity.setStatus(1);
|
|
|
|
|
domainEntity.setCreateTime(new Date());
|
|
|
|
|
domainEntity.setUpdateTime(new Date());
|
|
|
|
|
domainEntity.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
domainEntity.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
int b2 = privilageDomainDOMapper.insert(domainEntity);
|
|
|
|
|
//添加域和组织的关系
|
|
|
|
|
PrivilageOrganizationalDomain orgDomainEntity = new PrivilageOrganizationalDomain();
|
|
|
|
|
orgDomainEntity.setOrgId(entity.getId());
|
|
|
|
|
orgDomainEntity.setDomainId(domainEntity.getId());
|
|
|
|
|
int b3 = privilageOrganizationalDomainMapper.insert(orgDomainEntity);
|
|
|
|
|
return (b + b2 + b3) == 3;
|
|
|
|
|
}else{
|
|
|
|
|
return b > 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加店铺
|
|
|
|
|
* @param poiStore 店铺对象
|
|
|
|
|
* @return 返回 true成功 false失败
|
|
|
|
|
* @throws KiisooException 异常
|
|
|
|
|
*/
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public boolean addStore(PoiStoreVO poiStore) throws KiisooException {
|
|
|
|
|
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("code", poiStore.getCode());
|
|
|
|
|
List<PoiStore> list = poiStoreDOMapper.selectByMap(map);
|
|
|
|
|
if(CollectionUtils.isNotEmpty(list) && list.size() > 1){
|
|
|
|
|
throw new KiisooException(Constants.MSG_STORE_HAS, Constants.CODE_STORE_HAS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int b = poiStoreDOMapper.insert(poiStore);
|
|
|
|
|
|
|
|
|
|
//查看是否有客户
|
|
|
|
|
PrivilageOrganizational p = new PrivilageOrganizational();
|
|
|
|
|
p.setName(poiStore.getCustomerName());
|
|
|
|
|
p.setLevel(3L);
|
|
|
|
|
PrivilageOrganizational parent = retailCompanyMapper.selectOne(new QueryWrapper<>(p));
|
|
|
|
|
if (null == parent) {
|
|
|
|
|
throw new KiisooException(Constants.MSG_ORGANIZATIONAL_NO, Constants.CODE_ORGANIZATIONAL_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> domainMap = new HashMap<>();
|
|
|
|
|
domainMap.put("name", poiStore.getCustomerName());
|
|
|
|
|
domainMap.put("code", poiStore.getCustomerCode());
|
|
|
|
|
List<PrivilageDomainDO> domainList = privilageDomainDOMapper.selectByMap(domainMap);
|
|
|
|
|
|
|
|
|
|
if(CollectionUtils.isEmpty(domainList)){
|
|
|
|
|
throw new KiisooException(Constants.MSG_ORGANIZATIONAL_NO, Constants.CODE_ORGANIZATIONAL_NO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrivilageDomainDO domain = domainList.get(0);
|
|
|
|
|
|
|
|
|
|
//找到区域域
|
|
|
|
|
Map<String, Object> domainEntityMap = new HashMap<>();
|
|
|
|
|
domainEntityMap.put("entity_id", poiStore.getId());
|
|
|
|
|
List<PrivilageDomainEntityDO> domainEntityList = privilageDomainEntityDOMapper.selectByMap(domainEntityMap);
|
|
|
|
|
if (domainEntityList.size() > 1) {
|
|
|
|
|
throw new KiisooException(Constants.MSG_DOMAIN_ENTITY_HAS, Constants.CODE_DOMAIN_ENTITY_HAS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PrivilageDomainEntityDO privilageDomainEntityDO = new PrivilageDomainEntityDO();
|
|
|
|
|
privilageDomainEntityDO.setDomainId(domain.getId());
|
|
|
|
|
privilageDomainEntityDO.setEntityId(poiStore.getId());
|
|
|
|
|
privilageDomainEntityDO.setType(3);
|
|
|
|
|
privilageDomainEntityDO.setCreateTime(new Date());
|
|
|
|
|
privilageDomainEntityDO.setUpdateTime(new Date());
|
|
|
|
|
privilageDomainEntityDO.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
privilageDomainEntityDO.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
int b2 = privilageDomainEntityDOMapper.insert(privilageDomainEntityDO);
|
|
|
|
|
|
|
|
|
|
return (b+b2) == 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|