修改线索逻辑

master
bynt 5 months ago
parent 281a169db8
commit 6e11ff7ebe

@ -68,12 +68,12 @@ public interface ClueService extends ExtendService<ClueEntity> {
/** /**
* id * id
* @param companyId * @param assignedBy
* @param phone * @param phone
* @return * @return
* *
*/ */
List<ClueEntity> findByCompanyIdAndNid(Long companyId, String phone); Long findByAssignedByIdAndNid(Long assignedBy, String phone);
/** /**
* id * id

@ -254,9 +254,9 @@ public class ClueServiceImpl extends ExtendServiceImpl<ClueMapper, ClueEntity> i
} }
@Override @Override
public List<ClueEntity> findByCompanyIdAndNid(Long companyId, String phone) { public Long findByAssignedByIdAndNid(Long assignedById, String phone) {
return baseMapper.selectList(Wrappers.lambdaQuery(ClueEntity.class).eq return baseMapper.selectCount(Wrappers.lambdaQuery(ClueEntity.class).eq
(ClueEntity::getCompanyId, companyId).eq(ClueEntity::getNid, phone).eq (ClueEntity::getAssignedBy, assignedById).eq(ClueEntity::getNid, phone).eq
(ClueEntity::getDeleted,DefaultNumberConstants.ZERO_NUMBER)); (ClueEntity::getDeleted,DefaultNumberConstants.ZERO_NUMBER));
} }

@ -185,10 +185,7 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
if (ObjectUtil.isNotNull(customEntity) || customEntity.getEnrollStatus() != DefaultNumberConstants.TWO_NUMBER) { if (ObjectUtil.isNotNull(customEntity) || customEntity.getEnrollStatus() != DefaultNumberConstants.TWO_NUMBER) {
String phone = AESUtils.encrypt(customEntity.getCustomNid(), securityProperties.getPasswordSecretKey()); String phone = AESUtils.encrypt(customEntity.getCustomNid(), securityProperties.getPasswordSecretKey());
Long companyId = customEntity.getCompanyId(); Long companyId = customEntity.getCompanyId();
List<ClueEntity> clueEntityList = clueService.findByCompanyIdAndNid(companyId, phone);
if (CollUtil.isNotEmpty(clueEntityList)) {
throw new BadRequestException("该资源已分发,请勿重复操作!");
}
if (status == 0) { if (status == 0) {
Gson gson = new Gson(); Gson gson = new Gson();
AddressDTO address = new AddressDTO(); AddressDTO address = new AddressDTO();
@ -201,6 +198,10 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId(); Long clueId = IdUtil.getSnowflake(workerId, datacenterId).nextId();
StoreUserDTO entity = storeUserService.findUserIdByStoreId(store.getStoreId()); StoreUserDTO entity = storeUserService.findUserIdByStoreId(store.getStoreId());
if (ObjectUtil.isNotNull(entity) && ObjectUtil.isNotNull(entity.getUserId())) { if (ObjectUtil.isNotNull(entity) && ObjectUtil.isNotNull(entity.getUserId())) {
Long countResult = clueService.findByAssignedByIdAndNid(entity.getUserId(), phone);
if (ObjectUtil.isNotNull(countResult) && countResult > DefaultNumberConstants.ZERO_NUMBER) {
throw new BadRequestException("该资源已分发,请勿重复操作!");
}
String username = sysUserService.findById(entity.getUserId()).getUsername(); String username = sysUserService.findById(entity.getUserId()).getUsername();
// 扣减余额 // 扣减余额
Boolean result = sysUserService.deductionQuantity(entity.getUserId(), entity.getStoreName()); Boolean result = sysUserService.deductionQuantity(entity.getUserId(), entity.getStoreName());
@ -339,7 +340,10 @@ public class CustomServiceImpl extends ExtendServiceImpl<CustomMapper, CustomEnt
Boolean result = sysUserService.addQuantity(vo.getAssignedBy()); Boolean result = sysUserService.addQuantity(vo.getAssignedBy());
if (result.equals(Boolean.TRUE)) { if (result.equals(Boolean.TRUE)) {
// 删除线索 // 删除线索
clueService.removeById(Long.parseLong(vo.getClueId())); boolean removed = clueService.removeById(Long.parseLong(vo.getClueId()));
if (Boolean.FALSE.equals(removed)) {
throw new BadRequestException("撤回线索失败!");
}
} }
} }
// 修改状态 // 修改状态

Loading…
Cancel
Save