|
|
@ -30,7 +30,6 @@ import com.baiye.system.constant.LetterConst;
|
|
|
|
import com.baiye.system.enums.RoleCodeEnum;
|
|
|
|
import com.baiye.system.enums.RoleCodeEnum;
|
|
|
|
import com.baiye.system.model.entity.SysUser;
|
|
|
|
import com.baiye.system.model.entity.SysUser;
|
|
|
|
import com.baiye.system.service.SysUserRoleService;
|
|
|
|
import com.baiye.system.service.SysUserRoleService;
|
|
|
|
import com.baiye.system.model.entity.SysUser;
|
|
|
|
|
|
|
|
import com.baiye.system.service.SysUserService;
|
|
|
|
import com.baiye.system.service.SysUserService;
|
|
|
|
import com.baiye.util.AESUtils;
|
|
|
|
import com.baiye.util.AESUtils;
|
|
|
|
import com.baiye.utils.SerialCode;
|
|
|
|
import com.baiye.utils.SerialCode;
|
|
|
@ -48,6 +47,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
@ -67,13 +67,10 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
|
|
|
|
|
|
|
|
private final SysUserService sysUserService;
|
|
|
|
private final SysUserService sysUserService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ClueService clueService;
|
|
|
|
private final ClueService clueService;
|
|
|
|
|
|
|
|
|
|
|
|
private final StoreService storeService;
|
|
|
|
private final StoreService storeService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${snowflake.workerId}")
|
|
|
|
@Value("${snowflake.workerId}")
|
|
|
|
private int workerId;
|
|
|
|
private int workerId;
|
|
|
|
|
|
|
|
|
|
|
@ -83,18 +80,7 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public PageResult<CustomVO> queryPage(PageParam pageParam, CustomQo qo) {
|
|
|
|
public PageResult<CustomVO> queryPage(PageParam pageParam, CustomQo qo) {
|
|
|
|
PageResult<CustomVO> customVOPageResult = baseMapper.queryPage(pageParam, qo);
|
|
|
|
return baseMapper.queryPage(pageParam, qo);
|
|
|
|
/*List<CustomVO> records = customVOPageResult.getRecords();
|
|
|
|
|
|
|
|
// 返回数据处理
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(records)) {
|
|
|
|
|
|
|
|
for (CustomVO record : records) {
|
|
|
|
|
|
|
|
if (record.getEnrollStatus() == 2) {
|
|
|
|
|
|
|
|
StringBuilder stringBuilder = new StringBuilder(record.getCustomNid());
|
|
|
|
|
|
|
|
record.setCustomNid(stringBuilder.replace(3, 7, "****").toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
return customVOPageResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -105,8 +91,10 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
CustomEntity customEntity = getCustomEntity(CustomConverter.INSTANCE.dtoToPo(customDTO), user.getWhichUserId(), user.getUsername());
|
|
|
|
CustomEntity customEntity = getCustomEntity(CustomConverter.INSTANCE.dtoToPo(customDTO), user.getWhichUserId(), user.getUsername());
|
|
|
|
int insert = baseMapper.insert(customEntity);
|
|
|
|
int insert = baseMapper.insert(customEntity);
|
|
|
|
List<CustomStoreEntity> customStoreEntities = customDTO.getCustomStoreEntities();
|
|
|
|
List<CustomStoreEntity> customStoreEntities = customDTO.getCustomStoreEntities();
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(customStoreEntities)){
|
|
|
|
customStoreEntities.forEach(c -> c.setCustomId(customEntity.getCustomId()));
|
|
|
|
customStoreEntities.forEach(c -> c.setCustomId(customEntity.getCustomId()));
|
|
|
|
customStoreService.saveBatch(customStoreEntities);
|
|
|
|
customStoreService.saveBatch(customStoreEntities);
|
|
|
|
|
|
|
|
}
|
|
|
|
return SqlHelper.retBool(insert);
|
|
|
|
return SqlHelper.retBool(insert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -125,6 +113,9 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
CustomVO customVO = new CustomVO();
|
|
|
|
CustomVO customVO = new CustomVO();
|
|
|
|
CustomEntity customEntity = baseMapper.selectById(id);
|
|
|
|
CustomEntity customEntity = baseMapper.selectById(id);
|
|
|
|
BeanUtils.copyProperties(customEntity, customVO);
|
|
|
|
BeanUtils.copyProperties(customEntity, customVO);
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(customEntity.getSalesmanUserId())){
|
|
|
|
|
|
|
|
customVO.setSalesmanUserId(customEntity.getSalesmanUserId().stream().map(Long::parseLong).collect(Collectors.toList()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<CustomStoreVO> customStoreVOList = new ArrayList<>();
|
|
|
|
List<CustomStoreVO> customStoreVOList = new ArrayList<>();
|
|
|
|
List<CustomStoreEntity> customStores = customStoreService.selectListByCustomId(id);
|
|
|
|
List<CustomStoreEntity> customStores = customStoreService.selectListByCustomId(id);
|
|
|
@ -159,16 +150,13 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public Boolean auditFormById(CustomDTO customDTO) {
|
|
|
|
public Boolean auditFormById(ChangeCustomDTO dto) {
|
|
|
|
Long customId = customDTO.getCustomId();
|
|
|
|
Integer status = dto.getStatus();
|
|
|
|
Integer status = customDTO.getStatus();
|
|
|
|
List<Long> salesmanUserIdList = dto.getSalesmanUserId();
|
|
|
|
List<Long> salesmanUserIdList = customDTO.getSalesmanUserIdList();
|
|
|
|
|
|
|
|
Long reviewUserId = customDTO.getReviewUserId();
|
|
|
|
|
|
|
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
|
|
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
|
|
|
CustomEntity updateCustomEntity = CustomConverter.INSTANCE.dtoToPo(customDTO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ClueDTO> list = Lists.newArrayList();
|
|
|
|
List<ClueDTO> list = Lists.newArrayList();
|
|
|
|
CustomEntity customEntity = baseMapper.selectById(customId);
|
|
|
|
CustomEntity customEntity = baseMapper.selectById(dto.getCustomId());
|
|
|
|
if (ObjectUtil.isNotNull(customEntity)) {
|
|
|
|
if (ObjectUtil.isNotNull(customEntity)) {
|
|
|
|
String phone = AESUtils.encrypt(customEntity.getCustomNid(), securityProperties.getPasswordSecretKey());
|
|
|
|
String phone = AESUtils.encrypt(customEntity.getCustomNid(), securityProperties.getPasswordSecretKey());
|
|
|
|
Long companyId = customEntity.getCompanyId();
|
|
|
|
Long companyId = customEntity.getCompanyId();
|
|
|
@ -178,7 +166,7 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
BeanUtils.copyProperties(customEntity, address);
|
|
|
|
BeanUtils.copyProperties(customEntity, address);
|
|
|
|
address.setCustomerName(customEntity.getCustomName());
|
|
|
|
address.setCustomerName(customEntity.getCustomName());
|
|
|
|
String otherClue = gson.toJson(address);
|
|
|
|
String otherClue = gson.toJson(address);
|
|
|
|
List<CustomStoreEntity> customStores = customStoreService.selectListByCustomId(customId);
|
|
|
|
List<CustomStoreEntity> customStores = customStoreService.selectListByCustomId(dto.getCustomId());
|
|
|
|
if (CollUtil.isNotEmpty(customStores)) {
|
|
|
|
if (CollUtil.isNotEmpty(customStores)) {
|
|
|
|
for (CustomStoreEntity store : customStores) {
|
|
|
|
for (CustomStoreEntity store : customStores) {
|
|
|
|
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
|
|
|
|
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
|
|
|
@ -188,8 +176,8 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
// 扣减余额
|
|
|
|
// 扣减余额
|
|
|
|
Boolean result = sysUserService.deductionQuantity(entity.getUserId(), entity.getStoreName());
|
|
|
|
Boolean result = sysUserService.deductionQuantity(entity.getUserId(), entity.getStoreName());
|
|
|
|
if (Boolean.TRUE.equals(result)) {
|
|
|
|
if (Boolean.TRUE.equals(result)) {
|
|
|
|
ClueDTO clueDTO = new ClueDTO(clueId, ClueSourceEnum.STORE_DISTRIBUTION.getDescription(), phone, updateCustomEntity.getRemark(),
|
|
|
|
ClueDTO clueDTO = new ClueDTO(clueId, ClueSourceEnum.STORE_DISTRIBUTION.getDescription(), phone, customEntity.getRemark(),
|
|
|
|
otherClue, entity.getUserId(), username, currentUserId, Boolean.TRUE, companyId, updateCustomEntity.getSex(),
|
|
|
|
otherClue, entity.getUserId(), username, currentUserId, Boolean.TRUE, companyId, customEntity.getSex(),
|
|
|
|
customEntity.getCustomInformation(), customEntity.getChannelIdentifying(), customEntity.getChannelType());
|
|
|
|
customEntity.getCustomInformation(), customEntity.getChannelIdentifying(), customEntity.getChannelType());
|
|
|
|
list.add(clueDTO);
|
|
|
|
list.add(clueDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -205,25 +193,25 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
Boolean result = sysUserService.deductionQuantity(userId, null);
|
|
|
|
Boolean result = sysUserService.deductionQuantity(userId, null);
|
|
|
|
if (Boolean.TRUE.equals(result)) {
|
|
|
|
if (Boolean.TRUE.equals(result)) {
|
|
|
|
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
|
|
|
|
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
|
|
|
|
ClueDTO clueDTO = new ClueDTO(clueId, customEntity.getChannelName(), phone, updateCustomEntity.getRemark(), null, userId,
|
|
|
|
ClueDTO clueDTO = new ClueDTO(clueId, customEntity.getChannelName(), phone, customEntity.getRemark(), null, userId,
|
|
|
|
username, currentUserId, Boolean.TRUE, companyId, updateCustomEntity.getSex(), customEntity.getCustomInformation(),
|
|
|
|
username, currentUserId, Boolean.TRUE, companyId, customEntity.getSex(), customEntity.getCustomInformation(),
|
|
|
|
customEntity.getChannelIdentifying(), customEntity.getChannelType());
|
|
|
|
customEntity.getChannelIdentifying(), customEntity.getChannelType());
|
|
|
|
list.add(clueDTO);
|
|
|
|
list.add(clueDTO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (reviewUserId != null) throw new BadRequestException("复审员不能为空!");
|
|
|
|
if (ObjectUtil.isNull(dto.getReviewUserId())) throw new BadRequestException("复审员不能为空!");
|
|
|
|
updateCustomEntity.setType(3);
|
|
|
|
customEntity.setType(3);
|
|
|
|
updateCustomEntity.setReviewUserId(customDTO.getReviewUserId());
|
|
|
|
customEntity.setReviewUserId(dto.getReviewUserId());
|
|
|
|
return SqlHelper.retBool(baseMapper.updateById(updateCustomEntity));
|
|
|
|
return SqlHelper.retBool(baseMapper.updateById(customEntity));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 扣减数量,插入资源
|
|
|
|
// 插入资源,修改信息
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
updateCustomEntity.setEnrollStatus(2);
|
|
|
|
|
|
|
|
clueService.saveClueListByStoreInfo(list);
|
|
|
|
clueService.saveClueListByStoreInfo(list);
|
|
|
|
updateCustomEntity.setDistributeTime(DateUtil.date());
|
|
|
|
customEntity.setEnrollStatus(2);
|
|
|
|
updateCustomEntity.setUpdateTime(LocalDateTime.now());
|
|
|
|
customEntity.setDistributeTime(DateUtil.date());
|
|
|
|
return SqlHelper.retBool(baseMapper.updateById(updateCustomEntity));
|
|
|
|
customEntity.setUpdateTime(LocalDateTime.now());
|
|
|
|
|
|
|
|
return SqlHelper.retBool(baseMapper.updateById(customEntity));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Boolean.FALSE;
|
|
|
|
return Boolean.FALSE;
|
|
|
@ -311,8 +299,7 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
|
|
|
|
String detailAddress = customDTO.getDetailAddress();
|
|
|
|
String detailAddress = customDTO.getDetailAddress();
|
|
|
|
String radius = customDTO.getRadius();
|
|
|
|
String radius = customDTO.getRadius();
|
|
|
|
List<CustomStoreEntity> customStoreEntities = customDTO.getCustomStoreEntities();
|
|
|
|
List<CustomStoreEntity> customStoreEntities = customDTO.getCustomStoreEntities();
|
|
|
|
if (StringUtils.isBlank(economize) || StringUtils.isBlank(market))
|
|
|
|
if (StringUtils.isBlank(economize) || StringUtils.isBlank(market)) throw new BadRequestException("省市不能为空");
|
|
|
|
throw new BadRequestException("省市不能为空");
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(detailAddress)) throw new BadRequestException("详细地址不能为空");
|
|
|
|
if (StringUtils.isBlank(detailAddress)) throw new BadRequestException("详细地址不能为空");
|
|
|
|
if (StringUtils.isBlank(radius)) throw new BadRequestException("半径不能为空");
|
|
|
|
if (StringUtils.isBlank(radius)) throw new BadRequestException("半径不能为空");
|
|
|
|
if (CollUtil.isEmpty(customStoreEntities)) throw new BadRequestException("门店信息不能为空");
|
|
|
|
if (CollUtil.isEmpty(customStoreEntities)) throw new BadRequestException("门店信息不能为空");
|
|
|
|