|
@@ -44,8 +44,8 @@ import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
- * @description RepalCustomer 接口实现类
|
|
|
* @author Generator
|
|
|
+ * @description RepalCustomer 接口实现类
|
|
|
* @date 2022-04-08
|
|
|
*/
|
|
|
@Service
|
|
@@ -89,178 +89,178 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
UserContextBO userContextBO = UserContextUtil.getUser();
|
|
|
Long repalGroupId = repalGroupMemberService.getUserGroupId(userContextBO.getUserId());
|
|
|
List<RepalCustomer> repalCustomers = list(Wrappers.lambdaQuery(RepalCustomer.class)
|
|
|
- .eq(RepalCustomer::getRepalGroupId,repalGroupId)
|
|
|
- .eq(RepalCustomer::getDeleted,Dict.DeletedStatusEnunm.否.getCode())
|
|
|
- .eq(RepalCustomer::getCustType,custType)
|
|
|
+ .eq(RepalCustomer::getRepalGroupId, repalGroupId)
|
|
|
+ .eq(RepalCustomer::getDeleted, Dict.DeletedStatusEnunm.否.getCode())
|
|
|
+ .eq(RepalCustomer::getCustType, custType)
|
|
|
.like(StrUtil.isNotBlank(keyword), RepalCustomer::getCustName, keyword));
|
|
|
- if(CollUtil.isEmpty(repalCustomers)){
|
|
|
+ if (CollUtil.isEmpty(repalCustomers)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
List<RepalCustomerSimpleVO> result = new ArrayList<>(repalCustomers.size());
|
|
|
- for(RepalCustomer repalCustomer:repalCustomers){
|
|
|
+ for (RepalCustomer repalCustomer : repalCustomers) {
|
|
|
RepalCustomerSimpleVO repalCustomerSimpleVO = new RepalCustomerSimpleVO();
|
|
|
result.add(repalCustomerSimpleVO);
|
|
|
- BeanUtils.copyProperties(repalCustomer,repalCustomerSimpleVO);
|
|
|
+ BeanUtils.copyProperties(repalCustomer, repalCustomerSimpleVO);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public VOPage<RepalCustomerInfoVO> find(RepalCustomerQueryDTO dto,UserBean userBean) {
|
|
|
- //权限
|
|
|
- boolean allFlag = repalRolePermissionService.checkUserPermission(UserContextUtil.getUser().getUserId(),
|
|
|
- Dict.custTypeEnum.客户.getCode().equals(dto.getCustType()) ? PermissionEnum.QUERY_ALL_CUST.getCode() : PermissionEnum.QUERY_ALL_SUPPLY.getCode());
|
|
|
- //查组织id
|
|
|
- RepalGroupMember repalGroupMember = repalGroupMemberService.getOne(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
- .eq(RepalGroupMember::getUserId,userBean.getUserId())
|
|
|
- .eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()),false);
|
|
|
- if(ObjectUtil.isNull(repalGroupMember)){
|
|
|
- return new VOPage<>();
|
|
|
- }
|
|
|
- Page<RepalCustomerInfoBO> page = new Page<>(dto.getPageNum(),dto.getPageSize());
|
|
|
- int billType = Dict.custTypeEnum.客户.getCode().equals(dto.getCustType()) ? RepalBillTypeEnum.RECEIVABLE.getCode() : RepalBillTypeEnum.RECEIPT.getCode();
|
|
|
- page = repalCustomerMapper.getCustPage(page, repalGroupMember.getRepalGroupId(),dto.getCustProperty(),dto.getSortType(),dto.getCustType(),billType,allFlag,userBean.getUserId());
|
|
|
- VOPage<RepalCustomerInfoVO> result = new VOPage<>(dto.getPageNum(), dto.getPageSize(), page.getTotal(), new ArrayList<>());
|
|
|
- if(CollUtil.isEmpty(page.getRecords())){
|
|
|
- return result;
|
|
|
- }
|
|
|
- //查询负责人
|
|
|
- List<Long> custIds = page.getRecords().stream().map(RepalCustomerInfoBO::getCustId).collect(Collectors.toList());
|
|
|
- List<RepalCustChargeRel> rels = repalCustChargeRelService.list(Wrappers.lambdaQuery(RepalCustChargeRel.class)
|
|
|
- .in(RepalCustChargeRel::getCustId,custIds));
|
|
|
- Map<Long, List<RepalCustChargeRel>> relMap = rels.stream().collect(Collectors.groupingBy(RepalCustChargeRel::getCustId));
|
|
|
- Map<Long, RepalGroupMember> memberMap = new HashMap<>();
|
|
|
- if(CollUtil.isNotEmpty(rels)) {
|
|
|
- memberMap = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
- .in(RepalGroupMember::getUserId, rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList())).eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()))
|
|
|
- .stream().collect(Collectors.toMap(RepalGroupMember::getUserId, Function.identity(),(a,b)->a));
|
|
|
- }
|
|
|
- List<RepalCustomerInfoVO> voList = new ArrayList<>();
|
|
|
- for(RepalCustomerInfoBO customerInfo:page.getRecords()){
|
|
|
- RepalCustomerInfoVO vo = new RepalCustomerInfoVO();
|
|
|
- BeanUtils.copyProperties(customerInfo,vo);
|
|
|
- vo.setReceivableStr(customerInfo.getReceivable().stripTrailingZeros().toPlainString());
|
|
|
- vo.setTotalMoneyStr(customerInfo.getTotalMoney().stripTrailingZeros().toPlainString());
|
|
|
- //查询未读动态数量
|
|
|
- if(Dict.custTypeEnum.客户.getCode().equals(dto.getCustType())) {
|
|
|
- List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class)
|
|
|
- .eq(RepalBill::getCustomerId, customerInfo.getCustId())
|
|
|
- .eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
- if (CollUtil.isNotEmpty(repalBills)) {
|
|
|
- RepalBillRemindUnReadVO unRead = repalRemindHistoryService.getRemindUnReadVO(repalBills, userBean.getUserId(), null, null);
|
|
|
- if (ObjectUtil.isNotNull(unRead) && unRead.getUnreadTotalCount() > 0) {
|
|
|
- vo.setDynamicCountList(Stream.of(unRead.getUnreadOverdueCount(), unRead.getUnreadRiskCount(), unRead.getUnreadRankCount(), unRead.getUnreadFinanceCount()).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //负责人
|
|
|
- if(relMap.containsKey(customerInfo.getCustId())){
|
|
|
- List<RepalCustChargeRel> repalCustChargeRels = relMap.get(customerInfo.getCustId());
|
|
|
- List<RepalGroupMemberVO> memberList = new ArrayList<>();
|
|
|
- vo.setCharges(memberList);
|
|
|
- for(RepalCustChargeRel rel:repalCustChargeRels){
|
|
|
- RepalGroupMemberVO member = new RepalGroupMemberVO();
|
|
|
- memberList.add(member);
|
|
|
- RepalGroupMember groupMember = memberMap.getOrDefault(rel.getMemberUserId(),new RepalGroupMember());
|
|
|
- member.setMemberUserName(groupMember.getMemberUserName());
|
|
|
- member.setUserId(groupMember.getUserId());
|
|
|
- member.setId(groupMember.getId());
|
|
|
- member.setRepalGroupId(groupMember.getRepalGroupId());
|
|
|
- member.setRoleType(groupMember.getRoleType());
|
|
|
- }
|
|
|
- }
|
|
|
- voList.add(vo);
|
|
|
- }
|
|
|
- result.setDataList(voList);
|
|
|
- return result;
|
|
|
+ public VOPage<RepalCustomerInfoVO> find(RepalCustomerQueryDTO dto, UserBean userBean) {
|
|
|
+ //权限
|
|
|
+ boolean allFlag = repalRolePermissionService.checkUserPermission(UserContextUtil.getUser().getUserId(),
|
|
|
+ Dict.custTypeEnum.客户.getCode().equals(dto.getCustType()) ? PermissionEnum.QUERY_ALL_CUST.getCode() : PermissionEnum.QUERY_ALL_SUPPLY.getCode());
|
|
|
+ //查组织id
|
|
|
+ RepalGroupMember repalGroupMember = repalGroupMemberService.getOne(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
+ .eq(RepalGroupMember::getUserId, userBean.getUserId())
|
|
|
+ .eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()), false);
|
|
|
+ if (ObjectUtil.isNull(repalGroupMember)) {
|
|
|
+ return new VOPage<>();
|
|
|
+ }
|
|
|
+ Page<RepalCustomerInfoBO> page = new Page<>(dto.getPageNum(), dto.getPageSize());
|
|
|
+ int billType = Dict.custTypeEnum.客户.getCode().equals(dto.getCustType()) ? RepalBillTypeEnum.RECEIVABLE.getCode() : RepalBillTypeEnum.RECEIPT.getCode();
|
|
|
+ page = repalCustomerMapper.getCustPage(page, repalGroupMember.getRepalGroupId(), dto.getCustProperty(), dto.getSortType(), dto.getCustType(), billType, allFlag, userBean.getUserId());
|
|
|
+ VOPage<RepalCustomerInfoVO> result = new VOPage<>(dto.getPageNum(), dto.getPageSize(), page.getTotal(), new ArrayList<>());
|
|
|
+ if (CollUtil.isEmpty(page.getRecords())) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //查询负责人
|
|
|
+ List<Long> custIds = page.getRecords().stream().map(RepalCustomerInfoBO::getCustId).collect(Collectors.toList());
|
|
|
+ List<RepalCustChargeRel> rels = repalCustChargeRelService.list(Wrappers.lambdaQuery(RepalCustChargeRel.class)
|
|
|
+ .in(RepalCustChargeRel::getCustId, custIds));
|
|
|
+ Map<Long, List<RepalCustChargeRel>> relMap = rels.stream().collect(Collectors.groupingBy(RepalCustChargeRel::getCustId));
|
|
|
+ Map<Long, RepalGroupMember> memberMap = new HashMap<>();
|
|
|
+ if (CollUtil.isNotEmpty(rels)) {
|
|
|
+ memberMap = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
+ .in(RepalGroupMember::getUserId, rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList())).eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()))
|
|
|
+ .stream().collect(Collectors.toMap(RepalGroupMember::getUserId, Function.identity(), (a, b) -> a));
|
|
|
+ }
|
|
|
+ List<RepalCustomerInfoVO> voList = new ArrayList<>();
|
|
|
+ for (RepalCustomerInfoBO customerInfo : page.getRecords()) {
|
|
|
+ RepalCustomerInfoVO vo = new RepalCustomerInfoVO();
|
|
|
+ BeanUtils.copyProperties(customerInfo, vo);
|
|
|
+ vo.setReceivableStr(customerInfo.getReceivable().stripTrailingZeros().toPlainString());
|
|
|
+ vo.setTotalMoneyStr(customerInfo.getTotalMoney().stripTrailingZeros().toPlainString());
|
|
|
+ //查询未读动态数量
|
|
|
+ if (Dict.custTypeEnum.客户.getCode().equals(dto.getCustType())) {
|
|
|
+ List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class)
|
|
|
+ .eq(RepalBill::getCustomerId, customerInfo.getCustId())
|
|
|
+ .eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ if (CollUtil.isNotEmpty(repalBills)) {
|
|
|
+ RepalBillRemindUnReadVO unRead = repalRemindHistoryService.getRemindUnReadVO(repalBills, userBean.getUserId(), null, null);
|
|
|
+ if (ObjectUtil.isNotNull(unRead) && unRead.getUnreadTotalCount() > 0) {
|
|
|
+ vo.setDynamicCountList(Stream.of(unRead.getUnreadOverdueCount(), unRead.getUnreadRiskCount(), unRead.getUnreadRankCount(), unRead.getUnreadFinanceCount()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //负责人
|
|
|
+ if (relMap.containsKey(customerInfo.getCustId())) {
|
|
|
+ List<RepalCustChargeRel> repalCustChargeRels = relMap.get(customerInfo.getCustId());
|
|
|
+ List<RepalGroupMemberVO> memberList = new ArrayList<>();
|
|
|
+ vo.setCharges(memberList);
|
|
|
+ for (RepalCustChargeRel rel : repalCustChargeRels) {
|
|
|
+ RepalGroupMemberVO member = new RepalGroupMemberVO();
|
|
|
+ memberList.add(member);
|
|
|
+ RepalGroupMember groupMember = memberMap.getOrDefault(rel.getMemberUserId(), new RepalGroupMember());
|
|
|
+ member.setMemberUserName(groupMember.getMemberUserName());
|
|
|
+ member.setUserId(groupMember.getUserId());
|
|
|
+ member.setId(groupMember.getId());
|
|
|
+ member.setRepalGroupId(groupMember.getRepalGroupId());
|
|
|
+ member.setRoleType(groupMember.getRoleType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ voList.add(vo);
|
|
|
+ }
|
|
|
+ result.setDataList(voList);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public RepalCustomerDetailVO addCustomer(RepalCustomerDTO dto,UserBean userBean) {
|
|
|
+ public RepalCustomerDetailVO addCustomer(RepalCustomerDTO dto, UserBean userBean) {
|
|
|
boolean allFlag = repalRolePermissionService.checkUserPermission(UserContextUtil.getUser().getUserId(),
|
|
|
Dict.custTypeEnum.客户.getCode().equals(dto.getCustType()) ? PermissionEnum.ADD_CUST.getCode() : PermissionEnum.ADD_SUPPLY.getCode());
|
|
|
- if(!allFlag){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
+ if (!allFlag) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
//查组织id
|
|
|
RepalGroupMember repalGroupMember = repalGroupMemberService.getOne(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
- .eq(RepalGroupMember::getUserId,userBean.getUserId())
|
|
|
- .eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()),false);
|
|
|
- if(ObjectUtil.isNull(repalGroupMember)){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"您还未加入该组织,请联系超级管理员");
|
|
|
+ .eq(RepalGroupMember::getUserId, userBean.getUserId())
|
|
|
+ .eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()), false);
|
|
|
+ if (ObjectUtil.isNull(repalGroupMember)) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "您还未加入该组织,请联系超级管理员");
|
|
|
}
|
|
|
int repeatCount = count(Wrappers.lambdaQuery(RepalCustomer.class)
|
|
|
- .eq(RepalCustomer::getCustName,dto.getCustName())
|
|
|
- .eq(RepalCustomer::getCustType,dto.getCustType())
|
|
|
- .eq(RepalCustomer::getRepalGroupId,repalGroupMember.getRepalGroupId()));
|
|
|
- if(repeatCount > 0){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"不能重复添加客户或供应商");
|
|
|
- }
|
|
|
- RepalCustomer repalCustomer = new RepalCustomer();
|
|
|
- BeanUtils.copyProperties(dto,repalCustomer);
|
|
|
- repalCustomer.setRepalGroupId(repalGroupMember.getRepalGroupId());
|
|
|
- //校验非空字段
|
|
|
- if(StrUtil.isBlank(dto.getCustName())){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"客户名不能为空");
|
|
|
- }
|
|
|
- if(ObjectUtil.isNull(dto.getCustProperty())){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"客户性质不能为空");
|
|
|
- }
|
|
|
- save(repalCustomer);
|
|
|
-
|
|
|
- //保存联系人
|
|
|
- if(CollUtil.isNotEmpty(dto.getLinks())){
|
|
|
- List<RepalLink> links = new ArrayList<>();
|
|
|
- for(RepalLinkDTO linkDto: dto.getLinks()){
|
|
|
- RepalLink link = new RepalLink();
|
|
|
- BeanUtils.copyProperties(linkDto,link);
|
|
|
- link.setCustId(repalCustomer.getCustId());
|
|
|
- links.add(link);
|
|
|
- }
|
|
|
- repalLinkService.saveBatch(links);
|
|
|
- }
|
|
|
- //保存客户和负责人的关系
|
|
|
- if(CollUtil.isNotEmpty(dto.getCharges())){
|
|
|
- List<RepalCustChargeRel> rels = new ArrayList<>();
|
|
|
- for(Long relUserId: dto.getCharges()){
|
|
|
- RepalCustChargeRel rel = new RepalCustChargeRel();
|
|
|
- rel.setCustId(repalCustomer.getCustId());
|
|
|
- rel.setMemberUserId(relUserId);
|
|
|
- rels.add(rel);
|
|
|
- }
|
|
|
- repalCustChargeRelService.saveBatch(rels);
|
|
|
- }
|
|
|
- //添加操作日志
|
|
|
- Dict.ActionCodeEnum actionCodeEnum = Dict.ActionCodeEnum.新增客户;
|
|
|
- if(Dict.custTypeEnum.供应商.getCode().equals(dto.getCustType())){
|
|
|
- actionCodeEnum = Dict.ActionCodeEnum.新增供应商;
|
|
|
- }
|
|
|
- RepalBillOperLog repalBillOperLog = new RepalBillOperLog();
|
|
|
- repalBillOperLog.setActionCode(actionCodeEnum.getCode());
|
|
|
- repalBillOperLog.setUserId(userBean.getUserId());
|
|
|
- repalBillOperLog.setOperTime(LocalDateTime.now());
|
|
|
- repalBillOperLog.setBizId(String.valueOf(repalCustomer.getCustId()));
|
|
|
- repalBillOperLog.setBizType(actionCodeEnum.getBizType());
|
|
|
- repalBillOperLog.setActionName(actionCodeEnum.name());
|
|
|
- repalBillOperLogService.save(repalBillOperLog);
|
|
|
- return getDetailById(repalCustomer.getCustId(),userBean,dto.getCustType());
|
|
|
+ .eq(RepalCustomer::getCustName, dto.getCustName())
|
|
|
+ .eq(RepalCustomer::getCustType, dto.getCustType())
|
|
|
+ .eq(RepalCustomer::getRepalGroupId, repalGroupMember.getRepalGroupId()));
|
|
|
+ if (repeatCount > 0) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "不能重复添加客户或供应商");
|
|
|
+ }
|
|
|
+ RepalCustomer repalCustomer = new RepalCustomer();
|
|
|
+ BeanUtils.copyProperties(dto, repalCustomer);
|
|
|
+ repalCustomer.setRepalGroupId(repalGroupMember.getRepalGroupId());
|
|
|
+ //校验非空字段
|
|
|
+ if (StrUtil.isBlank(dto.getCustName())) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "客户名不能为空");
|
|
|
+ }
|
|
|
+ if (ObjectUtil.isNull(dto.getCustProperty())) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "客户性质不能为空");
|
|
|
+ }
|
|
|
+ save(repalCustomer);
|
|
|
+
|
|
|
+ //保存联系人
|
|
|
+ if (CollUtil.isNotEmpty(dto.getLinks())) {
|
|
|
+ List<RepalLink> links = new ArrayList<>();
|
|
|
+ for (RepalLinkDTO linkDto : dto.getLinks()) {
|
|
|
+ RepalLink link = new RepalLink();
|
|
|
+ BeanUtils.copyProperties(linkDto, link);
|
|
|
+ link.setCustId(repalCustomer.getCustId());
|
|
|
+ links.add(link);
|
|
|
+ }
|
|
|
+ repalLinkService.saveBatch(links);
|
|
|
+ }
|
|
|
+ //保存客户和负责人的关系
|
|
|
+ if (CollUtil.isNotEmpty(dto.getCharges())) {
|
|
|
+ List<RepalCustChargeRel> rels = new ArrayList<>();
|
|
|
+ for (Long relUserId : dto.getCharges()) {
|
|
|
+ RepalCustChargeRel rel = new RepalCustChargeRel();
|
|
|
+ rel.setCustId(repalCustomer.getCustId());
|
|
|
+ rel.setMemberUserId(relUserId);
|
|
|
+ rels.add(rel);
|
|
|
+ }
|
|
|
+ repalCustChargeRelService.saveBatch(rels);
|
|
|
+ }
|
|
|
+ //添加操作日志
|
|
|
+ Dict.ActionCodeEnum actionCodeEnum = Dict.ActionCodeEnum.新增客户;
|
|
|
+ if (Dict.custTypeEnum.供应商.getCode().equals(dto.getCustType())) {
|
|
|
+ actionCodeEnum = Dict.ActionCodeEnum.新增供应商;
|
|
|
+ }
|
|
|
+ RepalBillOperLog repalBillOperLog = new RepalBillOperLog();
|
|
|
+ repalBillOperLog.setActionCode(actionCodeEnum.getCode());
|
|
|
+ repalBillOperLog.setUserId(userBean.getUserId());
|
|
|
+ repalBillOperLog.setOperTime(LocalDateTime.now());
|
|
|
+ repalBillOperLog.setBizId(String.valueOf(repalCustomer.getCustId()));
|
|
|
+ repalBillOperLog.setBizType(actionCodeEnum.getBizType());
|
|
|
+ repalBillOperLog.setActionName(actionCodeEnum.name());
|
|
|
+ repalBillOperLogService.save(repalBillOperLog);
|
|
|
+ return getDetailById(repalCustomer.getCustId(), userBean, dto.getCustType());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public RepalCustomerDetailVO updateCustomer(RepalCustomerUpdateDTO dto, UserBean userBean) {
|
|
|
boolean allFlag = repalRolePermissionService.checkUserPermission(UserContextUtil.getUser().getUserId(),
|
|
|
Dict.custTypeEnum.客户.getCode().equals(dto.getCustType()) ? PermissionEnum.UPDATE_CUST.getCode() : PermissionEnum.UPDATE_SUPPLY.getCode());
|
|
|
- if(!allFlag){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
+ if (!allFlag) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
RepalCustomer repalCustomer = getById(dto.getCustId());
|
|
|
- if(ObjectUtil.isNull(repalCustomer)){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"客户或供应商不存在");
|
|
|
+ if (ObjectUtil.isNull(repalCustomer)) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "客户或供应商不存在");
|
|
|
}
|
|
|
RepalBillOperLog repalBillOperLog = new RepalBillOperLog();
|
|
|
List<RepalOperLogContentVO> operLogContents = new ArrayList<>();
|
|
|
- if(!ObjectUtil.equal(repalCustomer.getCustName(),dto.getCustName())){
|
|
|
+ if (!ObjectUtil.equal(repalCustomer.getCustName(), dto.getCustName())) {
|
|
|
RepalOperLogContentVO contentVO = new RepalOperLogContentVO();
|
|
|
contentVO.setPropertyName("custName");
|
|
|
contentVO.setPropertyCN("客户名称");
|
|
@@ -272,7 +272,7 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalCustomer.setCompanyId(dto.getCompanyId());
|
|
|
}
|
|
|
|
|
|
- if(!ObjectUtil.equal(repalCustomer.getCustProperty(),dto.getCustProperty())){
|
|
|
+ if (!ObjectUtil.equal(repalCustomer.getCustProperty(), dto.getCustProperty())) {
|
|
|
RepalOperLogContentVO contentVO = new RepalOperLogContentVO();
|
|
|
contentVO.setPropertyName("custProperty");
|
|
|
contentVO.setPropertyCN("客户性质");
|
|
@@ -283,7 +283,7 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalCustomer.setCustProperty(dto.getCustProperty());
|
|
|
}
|
|
|
|
|
|
- if(!ObjectUtil.equal(repalCustomer.getIndustry(),dto.getIndustry())){
|
|
|
+ if (!ObjectUtil.equal(repalCustomer.getIndustry(), dto.getIndustry())) {
|
|
|
RepalOperLogContentVO contentVO = new RepalOperLogContentVO();
|
|
|
contentVO.setPropertyName("industry");
|
|
|
contentVO.setPropertyCN("所属行业");
|
|
@@ -294,7 +294,7 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalCustomer.setIndustry(dto.getIndustry());
|
|
|
}
|
|
|
|
|
|
- if(!ObjectUtil.equal(repalCustomer.getIndustry(),dto.getIndustry())){
|
|
|
+ if (!ObjectUtil.equal(repalCustomer.getIndustry(), dto.getIndustry())) {
|
|
|
RepalOperLogContentVO contentVO = new RepalOperLogContentVO();
|
|
|
contentVO.setPropertyName("address");
|
|
|
contentVO.setPropertyCN("办公地址");
|
|
@@ -305,7 +305,7 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalCustomer.setAddress(dto.getAddress());
|
|
|
}
|
|
|
|
|
|
- if(!ObjectUtil.equal(repalCustomer.getAttachment(),dto.getAttachment())){
|
|
|
+ if (!ObjectUtil.equal(repalCustomer.getAttachment(), dto.getAttachment())) {
|
|
|
RepalOperLogContentVO contentVO = new RepalOperLogContentVO();
|
|
|
contentVO.setPropertyName("attachment");
|
|
|
contentVO.setPropertyCN("附件");
|
|
@@ -316,7 +316,7 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalCustomer.setAttachment(dto.getAttachment());
|
|
|
}
|
|
|
|
|
|
- if(!ObjectUtil.equal(repalCustomer.getRemark(),dto.getRemark())){
|
|
|
+ if (!ObjectUtil.equal(repalCustomer.getRemark(), dto.getRemark())) {
|
|
|
RepalOperLogContentVO contentVO = new RepalOperLogContentVO();
|
|
|
contentVO.setPropertyName("remark");
|
|
|
contentVO.setPropertyCN("备注信息");
|
|
@@ -329,23 +329,23 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
|
|
|
updateById(repalCustomer);
|
|
|
|
|
|
- if(CollUtil.isNotEmpty(dto.getCharges())){
|
|
|
- List<RepalCustChargeRel> rels = repalCustChargeRelService.list(Wrappers.lambdaQuery(RepalCustChargeRel.class).eq(RepalCustChargeRel::getCustId,dto.getCustId()));
|
|
|
+ if (CollUtil.isNotEmpty(dto.getCharges())) {
|
|
|
+ List<RepalCustChargeRel> rels = repalCustChargeRelService.list(Wrappers.lambdaQuery(RepalCustChargeRel.class).eq(RepalCustChargeRel::getCustId, dto.getCustId()));
|
|
|
List<RepalGroupMember> members = new ArrayList<>();
|
|
|
//删除旧负责人
|
|
|
- if(CollUtil.isNotEmpty(rels)){
|
|
|
+ if (CollUtil.isNotEmpty(rels)) {
|
|
|
repalCustChargeRelService.removeByIds(rels.stream().map(RepalCustChargeRel::getId).collect(Collectors.toList()));
|
|
|
members = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
- .in(RepalGroupMember::getUserId,rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList()))
|
|
|
- .eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ .in(RepalGroupMember::getUserId, rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList()))
|
|
|
+ .eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
}
|
|
|
List<RepalGroupMember> newMembers = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
- .in(RepalGroupMember::getUserId,dto.getCharges())
|
|
|
- .eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ .in(RepalGroupMember::getUserId, dto.getCharges())
|
|
|
+ .eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
//新增负责人
|
|
|
List<RepalCustChargeRel> newRels = new ArrayList<>();
|
|
|
- for(Long relUserId: dto.getCharges()){
|
|
|
- RepalCustChargeRel rel = new RepalCustChargeRel();
|
|
|
+ for (Long relUserId : dto.getCharges()) {
|
|
|
+ RepalCustChargeRel rel = new RepalCustChargeRel();
|
|
|
rel.setCustId(repalCustomer.getCustId());
|
|
|
rel.setMemberUserId(relUserId);
|
|
|
newRels.add(rel);
|
|
@@ -360,15 +360,15 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
operLogContents.add(contentVO);
|
|
|
}
|
|
|
|
|
|
- if(CollUtil.isNotEmpty(dto.getLinks())){
|
|
|
- List<RepalLink> links = repalLinkService.list(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId,dto.getCustId()).eq(RepalLink::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ if (CollUtil.isNotEmpty(dto.getLinks())) {
|
|
|
+ List<RepalLink> links = repalLinkService.list(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId, dto.getCustId()).eq(RepalLink::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
//遍历修改老数据
|
|
|
- if(CollUtil.isNotEmpty(links)){
|
|
|
- for(RepalLink repalLink:links){
|
|
|
- Optional<RepalLinkDTO> optionalRepalLink = dto.getLinks().stream().filter(x->repalLink.getId().equals(x.getId())).findFirst();
|
|
|
- if(optionalRepalLink.isPresent()){
|
|
|
- BeanUtils.copyProperties(optionalRepalLink.get(),repalLink);
|
|
|
- }else {
|
|
|
+ if (CollUtil.isNotEmpty(links)) {
|
|
|
+ for (RepalLink repalLink : links) {
|
|
|
+ Optional<RepalLinkDTO> optionalRepalLink = dto.getLinks().stream().filter(x -> repalLink.getId().equals(x.getId())).findFirst();
|
|
|
+ if (optionalRepalLink.isPresent()) {
|
|
|
+ BeanUtils.copyProperties(optionalRepalLink.get(), repalLink);
|
|
|
+ } else {
|
|
|
repalLink.setDeleted(Dict.DeletedStatusEnunm.是.getCode());
|
|
|
}
|
|
|
repalLinkService.updateById(repalLink);
|
|
@@ -376,12 +376,12 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
}
|
|
|
//遍历新数据
|
|
|
List<RepalLink> newlinks = new ArrayList<>();
|
|
|
- for(RepalLinkDTO linkDto: dto.getLinks()){
|
|
|
- if(ObjectUtil.isNotNull(linkDto.getId())){
|
|
|
+ for (RepalLinkDTO linkDto : dto.getLinks()) {
|
|
|
+ if (ObjectUtil.isNotNull(linkDto.getId())) {
|
|
|
continue;
|
|
|
}
|
|
|
RepalLink link = new RepalLink();
|
|
|
- BeanUtils.copyProperties(linkDto,link);
|
|
|
+ BeanUtils.copyProperties(linkDto, link);
|
|
|
link.setCustId(repalCustomer.getCustId());
|
|
|
newlinks.add(link);
|
|
|
}
|
|
@@ -396,7 +396,7 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
}
|
|
|
|
|
|
Dict.ActionCodeEnum actionCodeEnum = Dict.ActionCodeEnum.修改客户;
|
|
|
- if(Dict.custTypeEnum.供应商.getCode().equals(repalCustomer.getCustType())){
|
|
|
+ if (Dict.custTypeEnum.供应商.getCode().equals(repalCustomer.getCustType())) {
|
|
|
actionCodeEnum = Dict.ActionCodeEnum.修改供应商;
|
|
|
}
|
|
|
repalBillOperLog.setActionCode(actionCodeEnum.getCode());
|
|
@@ -407,28 +407,28 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalBillOperLog.setActionName(actionCodeEnum.name());
|
|
|
repalBillOperLog.setActionContent(JSON.toJSONString(operLogContents));
|
|
|
repalBillOperLogService.save(repalBillOperLog);
|
|
|
- return getDetailById(dto.getCustId(),userBean,dto.getCustType());
|
|
|
+ return getDetailById(dto.getCustId(), userBean, dto.getCustType());
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public RepalCustomerDetailVO getDetailById(Long custId,UserBean userBean,Integer custType) {
|
|
|
+ public RepalCustomerDetailVO getDetailById(Long custId, UserBean userBean, Integer custType) {
|
|
|
//不做权限判断,默认通过列表的权限
|
|
|
- RepalCustomer repalCustomer = getById(custId);
|
|
|
- if(ObjectUtil.isNull(repalCustomer)){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"客户或供应商不存在");
|
|
|
- }
|
|
|
+ RepalCustomer repalCustomer = getById(custId);
|
|
|
+ if (ObjectUtil.isNull(repalCustomer)) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "客户或供应商不存在");
|
|
|
+ }
|
|
|
RepalCustomerDetailVO result = new RepalCustomerDetailVO();
|
|
|
- BeanUtils.copyProperties(repalCustomer,result);
|
|
|
+ BeanUtils.copyProperties(repalCustomer, result);
|
|
|
//查询负责人
|
|
|
List<RepalCustChargeRel> rels = repalCustChargeRelService.list(Wrappers.lambdaQuery(RepalCustChargeRel.class)
|
|
|
- .eq(RepalCustChargeRel::getCustId,custId));
|
|
|
- if(CollUtil.isNotEmpty(rels)){
|
|
|
+ .eq(RepalCustChargeRel::getCustId, custId));
|
|
|
+ if (CollUtil.isNotEmpty(rels)) {
|
|
|
List<RepalGroupMember> repalGroupMembers = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
|
|
|
- .in(RepalGroupMember::getUserId,rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList()))
|
|
|
- .eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ .in(RepalGroupMember::getUserId, rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList()))
|
|
|
+ .eq(RepalGroupMember::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
List<RepalGroupMemberVO> memberList = new ArrayList<>();
|
|
|
result.setCharges(memberList);
|
|
|
- for(RepalGroupMember groupMember:repalGroupMembers){
|
|
|
+ for (RepalGroupMember groupMember : repalGroupMembers) {
|
|
|
RepalGroupMemberVO member = new RepalGroupMemberVO();
|
|
|
memberList.add(member);
|
|
|
member.setMemberUserName(groupMember.getMemberUserName());
|
|
@@ -457,16 +457,17 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
}
|
|
|
}
|
|
|
//账款汇总
|
|
|
- List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class).eq(RepalBill::getCustomerId,custId).eq(RepalBill::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
- if(CollUtil.isNotEmpty(repalBills)){
|
|
|
-
|
|
|
- result.setRepalBillCount(repalBills.size());
|
|
|
- result.setReceivableStr(repalBills.stream().map(RepalBill::getReceivable).reduce(BigDecimal.ZERO,BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
- result.setTotalMoneyStr(repalBills.stream().map(RepalBill::getTotalMoney).reduce(BigDecimal.ZERO,BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
- result.setTotalOverdueStr(repalBills.stream().filter(x-> RepalBillStatusEnum.OVERDUE.getCode().equals(x.getRepalBillStatus())).map(RepalBill::getReceivable).reduce(BigDecimal.ZERO,BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
- result.setTotalReceiptStr(repalBills.stream().map(RepalBill::getReceipt).reduce(BigDecimal.ZERO,BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
- //动态
|
|
|
- if(Dict.custTypeEnum.客户.getCode().equals(custType)) {
|
|
|
+ List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class).eq(RepalBill::getCustomerId, custId).eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ Map<Long, Integer> repalBillTypeMap = repalBills.stream().collect(Collectors.toMap(RepalBill::getId, RepalBill::getRepalBillType));
|
|
|
+ if (CollUtil.isNotEmpty(repalBills)) {
|
|
|
+
|
|
|
+ result.setRepalBillCount(repalBills.size());
|
|
|
+ result.setReceivableStr(repalBills.stream().map(RepalBill::getReceivable).reduce(BigDecimal.ZERO, BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
+ result.setTotalMoneyStr(repalBills.stream().map(RepalBill::getTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
+ result.setTotalOverdueStr(repalBills.stream().filter(x -> RepalBillStatusEnum.OVERDUE.getCode().equals(x.getRepalBillStatus())).map(RepalBill::getReceivable).reduce(BigDecimal.ZERO, BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
+ result.setTotalReceiptStr(repalBills.stream().map(RepalBill::getReceipt).reduce(BigDecimal.ZERO, BigDecimal::add).stripTrailingZeros().toPlainString());
|
|
|
+ //动态
|
|
|
+ if (Dict.custTypeEnum.客户.getCode().equals(custType)) {
|
|
|
RepalBillRemindUnReadVO unRead = repalRemindHistoryService.getRemindUnReadVO(repalBills, userBean.getUserId(), null, null);
|
|
|
if (ObjectUtil.isNotNull(unRead) && unRead.getUnreadTotalCount() > 0) {
|
|
|
result.setDynamicCountList(Stream.of(unRead.getUnreadOverdueCount(), unRead.getUnreadRiskCount(), unRead.getUnreadRankCount(), unRead.getUnreadFinanceCount()).collect(Collectors.toList()));
|
|
@@ -484,26 +485,40 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
billMoneyChange.setName(t.getOperUserName());
|
|
|
billMoneyChange.setChangeAmt(t.getTransMoney().setScale(2).toString());
|
|
|
billMoneyChange.setRepalChangeRecordId(t.getId());
|
|
|
+ StringBuilder desc = new StringBuilder(t.getOperUserName());
|
|
|
+ String repalBillTypeDesc = "";
|
|
|
+ if (repalBillTypeMap.containsKey(t.getRepalBillId())) {
|
|
|
+ repalBillTypeDesc = RepalBillTypeEnum.RECEIVABLE.getCode().equals(repalBillTypeMap.get(t.getRepalBillId())) ? "回" : "付";
|
|
|
+ } else {
|
|
|
+ repalBillTypeDesc = "回";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (DeletedStatusEnum.NORMAL.getCode().equals(t.getDeleted())) {
|
|
|
+ desc.append(Objects.isNull(t.getTimeModified()) ? "增加" : "编辑").append(repalBillTypeDesc);
|
|
|
+ } else {
|
|
|
+ desc.append("删除").append(repalBillTypeDesc);
|
|
|
+ }
|
|
|
+ billMoneyChange.setOperTypeDesc(desc.toString());
|
|
|
return billMoneyChange;
|
|
|
}).collect(Collectors.toList()));
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
result.setRepalBillCount(0);
|
|
|
result.setReceivableStr("0");
|
|
|
result.setTotalMoneyStr("0");
|
|
|
result.setTotalOverdueStr("0");
|
|
|
result.setTotalReceiptStr("0");
|
|
|
- result.setDynamicCountList(Arrays.asList(0,0,0,0));
|
|
|
+ result.setDynamicCountList(Arrays.asList(0, 0, 0, 0));
|
|
|
}
|
|
|
//联系人
|
|
|
- List<RepalLink> repalLinks = repalLinkService.list(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId,custId).eq(RepalLink::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
- if(CollUtil.isNotEmpty(repalLinks)){
|
|
|
+ List<RepalLink> repalLinks = repalLinkService.list(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId, custId).eq(RepalLink::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ if (CollUtil.isNotEmpty(repalLinks)) {
|
|
|
List<RepalLinkVO> repalLinkVOs = new ArrayList<>();
|
|
|
result.setLinks(repalLinkVOs);
|
|
|
- for(RepalLink repalLink:repalLinks){
|
|
|
+ for (RepalLink repalLink : repalLinks) {
|
|
|
RepalLinkVO repalLinkVO = new RepalLinkVO();
|
|
|
repalLinkVOs.add(repalLinkVO);
|
|
|
- BeanUtils.copyProperties(repalLink,repalLinkVO);
|
|
|
+ BeanUtils.copyProperties(repalLink, repalLinkVO);
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
@@ -513,26 +528,26 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
@Transactional
|
|
|
public Boolean deleteCustomer(Long custId, UserBean userBean) {
|
|
|
RepalCustomer repalCustomer = getById(custId);
|
|
|
- if(ObjectUtil.isNull(custId)){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"客户或供应商不存在");
|
|
|
+ if (ObjectUtil.isNull(custId)) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "客户或供应商不存在");
|
|
|
}
|
|
|
boolean allFlag = repalRolePermissionService.checkUserPermission(UserContextUtil.getUser().getUserId(),
|
|
|
Dict.custTypeEnum.客户.getCode().equals(repalCustomer.getCustType()) ? PermissionEnum.UPDATE_CUST.getCode() : PermissionEnum.UPDATE_SUPPLY.getCode());
|
|
|
- if(!allFlag){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
+ if (!allFlag) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "暂无此权限,可联系超级管理员在我的-成员管理页面开通");
|
|
|
}
|
|
|
repalCustomer.setDeleted(Dict.DeletedStatusEnunm.是.getCode());
|
|
|
updateById(repalCustomer);
|
|
|
//删除客户对应的账款
|
|
|
List<RepalBill> repalBills = repalBillService.list(Wrappers.lambdaQuery(RepalBill.class)
|
|
|
- .eq(RepalBill::getCustomerId,custId)
|
|
|
+ .eq(RepalBill::getCustomerId, custId)
|
|
|
.eq(RepalBill::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
- if(CollUtil.isNotEmpty(repalBills)){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"请先删除该"+(Dict.custTypeEnum.客户.getCode().equals(repalCustomer.getCustType()) ? Dict.custTypeEnum.客户.name() : Dict.custTypeEnum.供应商.name())+"的关联账款");
|
|
|
+ if (CollUtil.isNotEmpty(repalBills)) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "请先删除该" + (Dict.custTypeEnum.客户.getCode().equals(repalCustomer.getCustType()) ? Dict.custTypeEnum.客户.name() : Dict.custTypeEnum.供应商.name()) + "的关联账款");
|
|
|
}
|
|
|
//操作记录
|
|
|
Dict.ActionCodeEnum actionCodeEnum = Dict.ActionCodeEnum.删除客户;
|
|
|
- if(Dict.custTypeEnum.供应商.getCode().equals(repalCustomer.getCustType())){
|
|
|
+ if (Dict.custTypeEnum.供应商.getCode().equals(repalCustomer.getCustType())) {
|
|
|
actionCodeEnum = Dict.ActionCodeEnum.删除供应商;
|
|
|
}
|
|
|
RepalBillOperLog repalBillOperLog = new RepalBillOperLog();
|
|
@@ -548,13 +563,13 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
|
|
|
@Override
|
|
|
public List<RepalLinkVO> queryLink(Long custId) {
|
|
|
- List<RepalLink> repalLinks = repalLinkService.list(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId,custId).eq(RepalLink::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ List<RepalLink> repalLinks = repalLinkService.list(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId, custId).eq(RepalLink::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
List<RepalLinkVO> repalLinkVOs = new ArrayList<>();
|
|
|
- if(CollUtil.isNotEmpty(repalLinks)){
|
|
|
- for(RepalLink repalLink:repalLinks){
|
|
|
+ if (CollUtil.isNotEmpty(repalLinks)) {
|
|
|
+ for (RepalLink repalLink : repalLinks) {
|
|
|
RepalLinkVO repalLinkVO = new RepalLinkVO();
|
|
|
repalLinkVOs.add(repalLinkVO);
|
|
|
- BeanUtils.copyProperties(repalLink,repalLinkVO);
|
|
|
+ BeanUtils.copyProperties(repalLink, repalLinkVO);
|
|
|
}
|
|
|
}
|
|
|
return repalLinkVOs;
|
|
@@ -564,15 +579,15 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
public RepalLinkVO updateLink(RepalLinkUpdateDTO dto) {
|
|
|
RepalLinkVO result = new RepalLinkVO();
|
|
|
//如果是添加,检查是否满额
|
|
|
- if(ObjectUtil.isNull(dto.getId())){
|
|
|
- int count = repalLinkService.count(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId,dto.getCustId()).eq(RepalLink::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
- if(count > 4){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"联系人已满5人");
|
|
|
+ if (ObjectUtil.isNull(dto.getId())) {
|
|
|
+ int count = repalLinkService.count(Wrappers.lambdaQuery(RepalLink.class).eq(RepalLink::getCustId, dto.getCustId()).eq(RepalLink::getDeleted, Dict.DeletedStatusEnunm.否.getCode()));
|
|
|
+ if (count > 4) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "联系人已满5人");
|
|
|
}
|
|
|
RepalLink repalLink = new RepalLink();
|
|
|
- BeanUtils.copyProperties(dto,repalLink);
|
|
|
+ BeanUtils.copyProperties(dto, repalLink);
|
|
|
repalLinkService.save(repalLink);
|
|
|
- BeanUtils.copyProperties(repalLink,result);
|
|
|
+ BeanUtils.copyProperties(repalLink, result);
|
|
|
//操作记录
|
|
|
RepalBillOperLog repalBillOperLog = new RepalBillOperLog();
|
|
|
List<RepalOperLogContentVO> operLogContents = new ArrayList<>();
|
|
@@ -591,16 +606,16 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
|
|
|
repalBillOperLog.setActionName(actionCodeEnum.name());
|
|
|
repalBillOperLog.setActionContent(JSON.toJSONString(operLogContents));
|
|
|
repalBillOperLogService.save(repalBillOperLog);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
RepalLink repalLink = repalLinkService.getById(dto.getId());
|
|
|
- if(ObjectUtil.isNull(repalLink)){
|
|
|
- throw new CommonException(CodeMsg.FAILED,"联系人不存在");
|
|
|
+ if (ObjectUtil.isNull(repalLink)) {
|
|
|
+ throw new CommonException(CodeMsg.FAILED, "联系人不存在");
|
|
|
}
|
|
|
String oldValue = JSON.toJSONString(repalLink);
|
|
|
repalLink.setName(dto.getName());
|
|
|
repalLink.setMobileNo(dto.getMobileNo());
|
|
|
repalLinkService.updateById(repalLink);
|
|
|
- BeanUtils.copyProperties(repalLink,result);
|
|
|
+ BeanUtils.copyProperties(repalLink, result);
|
|
|
|
|
|
//操作记录
|
|
|
RepalBillOperLog repalBillOperLog = new RepalBillOperLog();
|