|
|
@@ -26,15 +26,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.redis.utils.RedisUtils;
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
import org.dromara.customer.domain.*;
|
|
|
-import org.dromara.customer.domain.bo.CustomerRegisterBo;
|
|
|
-import org.dromara.customer.domain.bo.EnterpriseScaleBo;
|
|
|
-import org.dromara.customer.domain.bo.SupplierAuthorizeBo;
|
|
|
-import org.dromara.customer.domain.bo.SupplyAreaBo;
|
|
|
+import org.dromara.customer.domain.bo.*;
|
|
|
import org.dromara.customer.domain.vo.*;
|
|
|
import org.dromara.customer.enums.SupplierStatusEnum;
|
|
|
-import org.dromara.customer.mapper.SupplierAuthorizeMapper;
|
|
|
-import org.dromara.customer.mapper.SupplierBusinessInfoMapper;
|
|
|
-import org.dromara.customer.mapper.SupplierContactMapper;
|
|
|
+import org.dromara.customer.mapper.*;
|
|
|
import org.dromara.customer.service.*;
|
|
|
import org.dromara.customer.utils.qcc.QccUtils;
|
|
|
import org.dromara.customer.utils.qcc.domain.CompanyInfoResponse;
|
|
|
@@ -48,10 +43,9 @@ import org.dromara.system.api.domain.bo.RemoteUserBo;
|
|
|
import org.dromara.system.api.domain.vo.RemoteSupplierTypeVo;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import org.dromara.customer.domain.bo.SupplierInfoBo;
|
|
|
import org.dromara.customer.domain.vo.SupplierInfoVo;
|
|
|
import org.dromara.customer.domain.SupplierInfo;
|
|
|
-import org.dromara.customer.mapper.SupplierInfoMapper;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
@@ -66,7 +60,7 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, SupplierInfo> implements ISupplierInfoService {
|
|
|
+public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, SupplierInfo> implements ISupplierInfoService {
|
|
|
|
|
|
private final SupplierInfoMapper baseMapper;
|
|
|
|
|
|
@@ -84,10 +78,11 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
private final ObjectMapper objectMapper;
|
|
|
|
|
|
+ private final SupplyAreaMapper supplyAreaMapper;
|
|
|
+
|
|
|
/**
|
|
|
- *
|
|
|
* 供应商联系人信息
|
|
|
- * */
|
|
|
+ */
|
|
|
private final SupplierContactMapper supplierContactMapper;
|
|
|
|
|
|
@DubboReference
|
|
|
@@ -106,8 +101,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
private final RemoteSupplierTypeService remoteSupplierTypeService;
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 新增供应商信息
|
|
|
*
|
|
|
@@ -137,11 +130,12 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 从JSON字符串解析工商信息并保存
|
|
|
*
|
|
|
* @param otherCustomersJson JSON格式的工商信息
|
|
|
- * @param supplierId 供应商ID
|
|
|
+ * @param supplierId 供应商ID
|
|
|
*/
|
|
|
private void saveSupplierBusinessInfoFromJson(String otherCustomersJson, Long supplierId) {
|
|
|
if (StringUtils.isBlank(otherCustomersJson)) {
|
|
|
@@ -172,7 +166,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 修改供应商信息
|
|
|
*
|
|
|
@@ -197,7 +190,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
supplierInfoVo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
//先copy到临时表
|
|
|
SupplierInfoTemporary supplierInfoTemporary = new SupplierInfoTemporary();
|
|
|
- BeanUtils.copyProperties(bo, supplierInfoTemporary,"id");
|
|
|
+ BeanUtils.copyProperties(bo, supplierInfoTemporary, "id");
|
|
|
//修改待审核
|
|
|
//ID一对一
|
|
|
supplierInfoTemporary.setSupplierId(bo.getId());
|
|
|
@@ -229,7 +222,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
//停用 ->正式供应商
|
|
|
- if (supplierInfoVo.getSupplyStatus() ==SupplierStatusEnum.DISABLED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
+ if (supplierInfoVo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode() && bo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
update.setCooperative(1L);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
@@ -262,7 +255,8 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
// 注意:泛型解析需要用 TypeReference 明确类型,否则会解析为 LinkedHashMap
|
|
|
TableDataInfo<SupplyAreaVo> areaTableData = objectMapper.readValue(
|
|
|
areaListJson,
|
|
|
- new TypeReference<TableDataInfo<SupplyAreaVo>>() {}
|
|
|
+ new TypeReference<TableDataInfo<SupplyAreaVo>>() {
|
|
|
+ }
|
|
|
);
|
|
|
// 2. 提取 SupplyAreaVo 列表(判空避免空指针)
|
|
|
List<SupplyAreaVo> supplyAreaVoList = areaTableData.getRows();
|
|
|
@@ -290,7 +284,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
// 5. 更新主表 SupplierInfo
|
|
|
supplierInfoVo.setSupplyStatus(SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode());
|
|
|
boolean updateMain = baseMapper.updateById(supplierInfoVo) > 0;
|
|
|
- if (updateMain == false){
|
|
|
+ if (updateMain == false) {
|
|
|
throw new RuntimeException("更新供应商信息失败");
|
|
|
}
|
|
|
boolean remove = supplierInfoTemporaryService.remove(new LambdaQueryWrapper<SupplierInfoTemporary>().eq(SupplierInfoTemporary::getSupplierId, id));
|
|
|
@@ -356,16 +350,16 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
Long id = bo.getId();
|
|
|
SupplierInfo supplierInfo = baseMapper.selectById(id);
|
|
|
//如果是待审核和审核不通过 随便改
|
|
|
- if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() || bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()){
|
|
|
+ if (bo.getSupplyStatus() == SupplierStatusEnum.PENDING_REVIEW.getCode() || bo.getSupplyStatus() == SupplierStatusEnum.REVIEW_FAILED.getCode()) {
|
|
|
SupplierInfo update = MapstructUtils.convert(bo, SupplierInfo.class);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
//如果是启用状态,就变成待修改审核状态
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()){
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.OFFICIAL_SUPPLIER.getCode()) {
|
|
|
SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
- if (supplierInfoTemporary == null){
|
|
|
+ if (supplierInfoTemporary == null) {
|
|
|
supplierInfoTemporary = new SupplierInfoTemporary();
|
|
|
- BeanUtils.copyProperties(supplierInfo, supplierInfoTemporary,"id");
|
|
|
+ BeanUtils.copyProperties(supplierInfo, supplierInfoTemporary, "id");
|
|
|
supplierInfoTemporary.setSupplierId(id);
|
|
|
//通过传参在set临时表
|
|
|
//查询供应地址 存入 areaListJson 为了回显
|
|
|
@@ -377,57 +371,57 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
supplierInfoTemporary.setAreaListJson(areaListJson);
|
|
|
supplierInfoTemporary.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
boolean save = supplierInfoTemporaryService.save(supplierInfoTemporary);
|
|
|
- if (save == false){
|
|
|
+ if (save == false) {
|
|
|
throw new RuntimeException("保存供应商待审核数据失败");
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//一共三个地方
|
|
|
- boolean flag =false;
|
|
|
+ boolean flag = false;
|
|
|
//1.简称
|
|
|
- if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
+ if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())) {
|
|
|
supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
|
//2.供货品牌
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
|
//3.供货类目
|
|
|
- if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
+ if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())) {
|
|
|
supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
|
|
|
|
supplierInfo.setSupplyStatus(SupplierStatusEnum.REVIEW_UPDATED.getCode());
|
|
|
- boolean update =baseMapper.updateById(supplierInfo) > 0;
|
|
|
+ boolean update = baseMapper.updateById(supplierInfo) > 0;
|
|
|
return update && flag;
|
|
|
}
|
|
|
//如果是待审核状态,依旧是待修改审核状态
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()){
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
SupplierInfoTemporary supplierInfoTemporary = supplierInfoTemporaryService.querBySupplierId(id);
|
|
|
//一共三个地方
|
|
|
- boolean flag =false;
|
|
|
+ boolean flag = false;
|
|
|
//1.简称
|
|
|
- if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())){
|
|
|
+ if (bo.getShortName() != null && StringUtils.isNotBlank(bo.getShortName())) {
|
|
|
supplierInfoTemporary.setShortName(bo.getShortName());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
|
//2.供货品牌
|
|
|
- if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
supplierInfoTemporary.setOperatingBrand(bo.getOperatingBrand());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
|
//3.供货类目
|
|
|
- if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())){
|
|
|
+ if (bo.getOperatingCategory() != null && StringUtils.isNotBlank(bo.getOperatingCategory())) {
|
|
|
supplierInfoTemporary.setOperatingCategory(bo.getOperatingCategory());
|
|
|
flag = supplierInfoTemporaryService.updateById(supplierInfoTemporary);
|
|
|
}
|
|
|
return flag;
|
|
|
}
|
|
|
// 停用呢 不能修改了
|
|
|
- if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()){
|
|
|
+ if (supplierInfo.getSupplyStatus() == SupplierStatusEnum.DISABLED.getCode()) {
|
|
|
throw new RuntimeException("供应商已停用,不能修改");
|
|
|
}
|
|
|
return false;
|
|
|
@@ -458,11 +452,11 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
public SupplierInfoVo queryById(Long id) throws JsonProcessingException {
|
|
|
SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
|
|
|
.eq(SupplierInfo::getId, id));
|
|
|
- SupplierInfoVo supplierInfoVo =new SupplierInfoVo();
|
|
|
+ SupplierInfoVo supplierInfoVo = new SupplierInfoVo();
|
|
|
if (supplierInfoVo1.getSupplyStatus() == SupplierStatusEnum.REVIEW_UPDATED.getCode()) {
|
|
|
SupplierInfoTemporaryVo supplierInfoTemporaryVo = supplierInfoTemporaryService.getVoOne(id);
|
|
|
BeanUtils.copyProperties(supplierInfoTemporaryVo, supplierInfoVo);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
supplierInfoVo = baseMapper.selectVoById(id);
|
|
|
}
|
|
|
SupplierInfoVo supplierInformationVo = handleProcurementInfo(supplierInfoVo);
|
|
|
@@ -478,7 +472,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 分页查询供应商信息列表
|
|
|
*
|
|
|
@@ -497,18 +490,18 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
public TableDataInfo<SupplierInfoVo> getSupplierInformation(SupplierInfoBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
// 1. 基础分页查询
|
|
|
- if (bo.getSupplyStatus() == null){
|
|
|
+ if (bo.getSupplyStatus() == null) {
|
|
|
//正式供应商
|
|
|
lqw.eq(SupplierInfo::getSupplyStatus, 1L);
|
|
|
- }else {
|
|
|
- lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
+ } else {
|
|
|
+ lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
|
|
|
}
|
|
|
|
|
|
// 2. 添加品牌条件
|
|
|
- if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
- if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
- if (productBrandIdByName != null){
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
|
}
|
|
|
@@ -556,7 +549,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<SupplierInfoVo> getSupplierApproveInformation(SupplierInfoBo bo, PageQuery pageQuery) {
|
|
|
- if (bo.getSupplyStatus() == null){
|
|
|
+ if (bo.getSupplyStatus() == null) {
|
|
|
// 步骤1:定义两个列表,存储主表(状态0)和临时表(状态4)的数据
|
|
|
List<SupplierInfoVo> mainTableVoList = new ArrayList<>();
|
|
|
List<SupplierInfoVo> tempTableVoList = new ArrayList<>();
|
|
|
@@ -664,13 +657,13 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
// 1. 构建审批状态条件
|
|
|
LambdaQueryWrapper<SupplierInfo> lqw = new LambdaQueryWrapper<>();
|
|
|
- lqw.eq(SupplierInfo::getSupplyStatus,bo.getSupplyStatus());
|
|
|
+ lqw.eq(SupplierInfo::getSupplyStatus, bo.getSupplyStatus());
|
|
|
|
|
|
// 2.添加品牌条件
|
|
|
- if (bo.getOperatingBrand()!= null && StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
- if (StringUtils.isNotBlank(bo.getOperatingBrand())){
|
|
|
+ if (bo.getOperatingBrand() != null && StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
+ if (StringUtils.isNotBlank(bo.getOperatingBrand())) {
|
|
|
Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getOperatingBrand());
|
|
|
- if (productBrandIdByName != null){
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
|
}
|
|
|
@@ -813,9 +806,9 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getSupplierName()), SupplierInfo::getEnterpriseName, bo.getSupplierName());
|
|
|
|
|
|
//可供应品牌
|
|
|
- if (StringUtils.isNotBlank(bo.getSupplyBrand())){
|
|
|
+ if (StringUtils.isNotBlank(bo.getSupplyBrand())) {
|
|
|
Long productBrandIdByName = remoteProductService.getProductBrandIdByName(bo.getSupplyBrand());
|
|
|
- if (productBrandIdByName != null){
|
|
|
+ if (productBrandIdByName != null) {
|
|
|
lqw.like(SupplierInfo::getOperatingBrand, productBrandIdByName);
|
|
|
}
|
|
|
}
|
|
|
@@ -823,10 +816,10 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
if (StringUtils.isNotBlank(bo.getProvince()) || StringUtils.isNotBlank(bo.getCity())) {
|
|
|
// 查询符合条件的供应商ID列表
|
|
|
List<Long> supplierIds = supplyAreaService.getSupplierIdsByArea(bo.getProvince(), bo.getCity());
|
|
|
- if (supplierIds != null &&!supplierIds.isEmpty()) {
|
|
|
+ if (supplierIds != null && !supplierIds.isEmpty()) {
|
|
|
lqw.in(SupplierInfo::getId, supplierIds);
|
|
|
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lqw.in(SupplierInfo::getId, -1L);
|
|
|
|
|
|
}
|
|
|
@@ -836,9 +829,9 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
if (StringUtils.isNotBlank(bo.getBrandName())) {
|
|
|
// 通过SupplierAuthorizeService查询符合条件的供应商ID
|
|
|
List<Long> supplierIdsByBrand = commonSupplierAuthorizeMapper.getSupplierIdsByBrandName(bo.getBrandName());
|
|
|
- if (supplierIdsByBrand!=null &&!supplierIdsByBrand.isEmpty()) {
|
|
|
+ if (supplierIdsByBrand != null && !supplierIdsByBrand.isEmpty()) {
|
|
|
lqw.in(SupplierInfo::getId, supplierIdsByBrand);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
lqw.in(SupplierInfo::getId, -1L);
|
|
|
|
|
|
}
|
|
|
@@ -889,7 +882,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
@Override
|
|
|
public Long getSupplierStatus(Long id) {
|
|
|
SupplierInfoVo supplierInfoVo1 = baseMapper.selectVoOne(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getSupplyStatus)
|
|
|
- .eq(SupplierInfo::getId,id));
|
|
|
+ .eq(SupplierInfo::getId, id));
|
|
|
|
|
|
return supplierInfoVo1.getSupplyStatus();
|
|
|
}
|
|
|
@@ -941,6 +934,7 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
// ========== 3. 数据转换 - 映射构建方法 ==========
|
|
|
+
|
|
|
/**
|
|
|
* 构建品牌ID→名称映射表
|
|
|
*/
|
|
|
@@ -1421,7 +1415,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private SupplierInfoVo handleProcurementInfo(SupplierInfoVo records) {
|
|
|
|
|
|
// 查询管理人员和采购人员
|
|
|
@@ -1565,7 +1558,6 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
}*/
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 处理采购员和产品经理信息和品牌和供应商类型
|
|
|
*/
|
|
|
@@ -1951,12 +1943,18 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
* @param bo
|
|
|
*/
|
|
|
@Override
|
|
|
- public Boolean register(CustomerRegisterBo bo) {
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Boolean register(SupplierRegisterBo bo) {
|
|
|
//先校验验证码是否正确
|
|
|
String code = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + bo.getPurchasePhone());
|
|
|
- code = "123456";
|
|
|
+
|
|
|
+ if (code == null) {
|
|
|
+ throw new ServiceException("验证码已过期");
|
|
|
+ }
|
|
|
+
|
|
|
if (!code.equals(bo.getCode())) {
|
|
|
throw new ServiceException("验证码错误");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//校验密码与确认密码是否一致
|
|
|
@@ -1966,23 +1964,47 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
//查询数据库是否存在企业,已存在则提示客户已存在
|
|
|
SupplierInfo one = baseMapper.selectOne(new LambdaQueryWrapper<SupplierInfo>()
|
|
|
- .eq(SupplierInfo::getSupplierName, bo.getCustomerName())
|
|
|
+ .eq(SupplierInfo::getSupplierName, bo.getEnterpriseName())
|
|
|
);
|
|
|
+
|
|
|
if (one != null) {
|
|
|
- throw new ServiceException("客户已存在");
|
|
|
+ throw new ServiceException("供应商已存在");
|
|
|
}
|
|
|
|
|
|
//查询企查查是否存在企业,如果企查查不存在则提示企业不存在
|
|
|
- CompanyInfoResponse companyInfo = QccUtils.getCompanyInfo(bo.getCustomerName());
|
|
|
+ CompanyInfoResponse companyInfo = QccUtils.getCompanyInfo(bo.getEnterpriseName());
|
|
|
if (companyInfo == null || companyInfo.getResult() == null) {
|
|
|
throw new ServiceException("请检查企业名是否正确");
|
|
|
}
|
|
|
|
|
|
//构建客户信息实体
|
|
|
SupplierInfo supplierInfo = new SupplierInfo();
|
|
|
- supplierInfo.setSupplierName(bo.getCustomerName());
|
|
|
- supplierInfo.setSupplierName(companyInfo.getResult().getName());
|
|
|
+ LambdaQueryWrapper<SupplierInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ // 按supplier_no降序排序,取第一条(最大值)
|
|
|
+ lambdaQueryWrapper.select(SupplierInfo::getSupplierNo)
|
|
|
+ .orderByDesc(SupplierInfo::getSupplierNo)
|
|
|
+ .last("LIMIT 1");
|
|
|
+ SupplierInfo maxSupplier = baseMapper.selectOne(lambdaQueryWrapper);
|
|
|
+ long l = Long.parseLong(maxSupplier.getSupplierNo()) + 1;
|
|
|
+ supplierInfo.setSupplierNo(String.valueOf(l));
|
|
|
+ // supplierInfo.setSupplierName(bo.getCustomerName()); //表中的该字段是表示 供应商联系人的名称
|
|
|
+ supplierInfo.setEnterpriseName(bo.getEnterpriseName());//表示供应商名称
|
|
|
+ supplierInfo.setBusinessName(companyInfo.getResult().getName());//表示供应商的工商名称
|
|
|
+ supplierInfo.setInvoiceHeader(companyInfo.getResult().getName());
|
|
|
supplierInfo.setShortName(companyInfo.getResult().getName());
|
|
|
+ supplierInfo.setMembershipSize(bo.getMembershipSize());
|
|
|
+ supplierInfo.setFixedPhone(bo.getFixedPhone());
|
|
|
+ supplierInfo.setFax(bo.getFax());
|
|
|
+ supplierInfo.setUrl(bo.getUrl());
|
|
|
+ supplierInfo.setMailbox(bo.getMailbox());
|
|
|
+ supplierInfo.setOfficeProvince(bo.getOfficeProvince());
|
|
|
+ supplierInfo.setOfficeCity(bo.getOfficeCity());
|
|
|
+ supplierInfo.setOfficeCounty(bo.getOfficeCounty());
|
|
|
+ supplierInfo.setOfficeAddress(bo.getOfficeAddress());
|
|
|
+ supplierInfo.setSocialCreditCode(companyInfo.getResult().getCreditCode());
|
|
|
+ supplierInfo.setYearSales(bo.getYearSales());
|
|
|
+ supplierInfo.setOperatingCategory(bo.getOperatingCategory());
|
|
|
+ supplierInfo.setBusinessLicense(bo.getBusinessLicense());
|
|
|
|
|
|
// 设置其他工商信息
|
|
|
if (baseMapper.insert(supplierInfo) <= 0) {
|
|
|
@@ -1991,27 +2013,49 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
Long supplierId = supplierInfo.getId();
|
|
|
|
|
|
+ String supplierNo = supplierInfo.getSupplierNo();
|
|
|
+
|
|
|
// 添加客户工商信息
|
|
|
SupplierBusinessInfo businessInfo = new SupplierBusinessInfo();
|
|
|
businessInfo.setSupplierId(supplierId);
|
|
|
businessInfo.setBusinessName(companyInfo.getResult().getName());
|
|
|
businessInfo.setSocialCreditCode(companyInfo.getResult().getCreditCode());
|
|
|
businessInfo.setLegalPersonName(companyInfo.getResult().getOperName());
|
|
|
- businessInfo.setRegisteredCapital(companyInfo.getResult().getRegistCapi());
|
|
|
+// businessInfo.setRegisteredCapital(companyInfo.getResult().getRegistCapi());
|
|
|
+ // 注册资本:拼接数值 + 单位(如 "101万元")
|
|
|
+ String regCap = companyInfo.getResult().getRegisteredCapital();
|
|
|
+ String regUnit = companyInfo.getResult().getRegisteredCapitalUnit();
|
|
|
+ businessInfo.setRegisteredCapital(
|
|
|
+ StringUtils.isNotBlank(regCap) && StringUtils.isNotBlank(regUnit)
|
|
|
+ ? regCap + regUnit
|
|
|
+ : regCap
|
|
|
+ );
|
|
|
+
|
|
|
+ // 实缴资本
|
|
|
+ String paidCap = companyInfo.getResult().getPaidUpCapital();
|
|
|
+ String paidUnit = companyInfo.getResult().getPaidUpCapitalUnit();
|
|
|
+ businessInfo.setPaidInCapital(
|
|
|
+ StringUtils.isNotBlank(paidCap) && StringUtils.isNotBlank(paidUnit)
|
|
|
+ ? paidCap + paidUnit
|
|
|
+ : paidCap
|
|
|
+ );
|
|
|
+
|
|
|
businessInfo.setEstablishmentDate(DateUtils.parseDate((companyInfo.getResult().getStartDate())));
|
|
|
businessInfo.setRegistrationStatus(companyInfo.getResult().getStatus());
|
|
|
+ businessInfo.setRegistrationAuthority(companyInfo.getResult().getBelongOrg());
|
|
|
businessInfo.setBusinessAddress(companyInfo.getResult().getAddress());
|
|
|
businessInfo.setBussinessRange(companyInfo.getResult().getScope());
|
|
|
businessInfo.setStatus("0");
|
|
|
businessInfo.setDelFlag("0");
|
|
|
|
|
|
if (supplierBusinessInfoMapper.insert(businessInfo) <= 0) {
|
|
|
- throw new ServiceException("客户工商信息新增失败");
|
|
|
+ throw new ServiceException("供应商工商信息新增失败");
|
|
|
}
|
|
|
|
|
|
// 添加客户联系人信息
|
|
|
SupplierContact contact = new SupplierContact();
|
|
|
contact.setSupplierId(supplierId);
|
|
|
+ contact.setSupplierNo(supplierNo);
|
|
|
contact.setUserName(bo.getPurchaseName());
|
|
|
contact.setPhone(bo.getPurchasePhone());
|
|
|
contact.setPhone(bo.getPurchasePhone());
|
|
|
@@ -2021,13 +2065,44 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
contact.setDelFlag("0");
|
|
|
|
|
|
if (supplierContactMapper.insert(contact) <= 0) {
|
|
|
- throw new ServiceException("客户联系人信息新增失败");
|
|
|
+ throw new ServiceException("供应商联系人信息新增失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SupplyAreaBo> supplyAreaList = bo.getSupplyAreaList();
|
|
|
+ if (supplyAreaList == null || supplyAreaList.isEmpty()) {
|
|
|
+ throw new ServiceException("供应商供应区域为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1. 内存中转换对象
|
|
|
+ List<SupplyArea> insertList = new ArrayList<>(supplyAreaList.size());
|
|
|
+ Set<String> uniqueCodes = new HashSet<>();
|
|
|
+ for (SupplyAreaBo area : supplyAreaList) {
|
|
|
+ if (!uniqueCodes.add(area.getAreaCode())) {
|
|
|
+ throw new ServiceException("供应区域代码 [" + area.getAreaCode() + "] 重复");
|
|
|
+ }
|
|
|
+ SupplyArea supplyArea = new SupplyArea();
|
|
|
+ supplyArea.setSupplierId(supplierId);
|
|
|
+ supplyArea.setSupplyNo(supplierNo);
|
|
|
+ supplyArea.setAreaCode(area.getAreaCode());
|
|
|
+ supplyArea.setAreaName(area.getAreaName());
|
|
|
+ supplyArea.setParentCode(area.getParentCode());
|
|
|
+ supplyArea.setLevel(area.getLevel());
|
|
|
+ supplyArea.setDelFlag("0");
|
|
|
+ supplyArea.setStatus("0");
|
|
|
+ insertList.add(supplyArea);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 执行批量插入
|
|
|
+ boolean b = supplyAreaMapper.insertBatch(insertList);
|
|
|
+
|
|
|
+ if (!b) {
|
|
|
+ throw new ServiceException("供应商供应区域信息批量新增失败");
|
|
|
}
|
|
|
|
|
|
// 创建系统用户
|
|
|
RemoteUserBo remoteUserBo = new RemoteUserBo();
|
|
|
remoteUserBo.setUserName(bo.getPurchasePhone());
|
|
|
- remoteUserBo.setNickName(bo.getCustomerName());
|
|
|
+ remoteUserBo.setNickName(bo.getPurchaseName());
|
|
|
remoteUserBo.setPhonenumber(bo.getPurchasePhone());
|
|
|
remoteUserBo.setPassword(BCrypt.hashpw(bo.getPassword()));
|
|
|
remoteUserBo.setUserSonType("3"); // 商城用户
|
|
|
@@ -2036,13 +2111,13 @@ public class SupplierInfoServiceImpl extends ServiceImpl<SupplierInfoMapper, Su
|
|
|
|
|
|
remoteUserService.addUser(remoteUserBo);
|
|
|
|
|
|
- log.info("客户注册成功,客户ID:{},客户名称:{}", supplierId, bo.getCustomerName());
|
|
|
+ log.info("供应商注册成功,供应商ID:{},供应商名称:{}", supplierId, bo.getEnterpriseName());
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<SupplierInfoVo> getNameList() {
|
|
|
- List<SupplierInfoVo> supplierInfoVos = baseMapper.selectVoList(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getId, SupplierInfo::getEnterpriseName,SupplierInfo::getSupplierNo));
|
|
|
+ List<SupplierInfoVo> supplierInfoVos = baseMapper.selectVoList(new LambdaQueryWrapper<SupplierInfo>().select(SupplierInfo::getId, SupplierInfo::getEnterpriseName, SupplierInfo::getSupplierNo));
|
|
|
return supplierInfoVos;
|
|
|
}
|
|
|
}
|