|
@@ -107,6 +107,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
private final SupplierBusinessInfoMapper supplierBusinessInfoMapper;
|
|
private final SupplierBusinessInfoMapper supplierBusinessInfoMapper;
|
|
|
private final TeamMemberMapper teamMemberMapper;
|
|
private final TeamMemberMapper teamMemberMapper;
|
|
|
private final CrmStaffMapper crmStaffMapper;
|
|
private final CrmStaffMapper crmStaffMapper;
|
|
|
|
|
+ private final CustomerShippingAddressMapper shippingAddressMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -733,19 +734,37 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
Map<String, Object> params = bo.getParams();
|
|
Map<String, Object> params = bo.getParams();
|
|
|
LambdaQueryWrapper<CustomerInfo> lqw = Wrappers.lambdaQuery();
|
|
LambdaQueryWrapper<CustomerInfo> lqw = Wrappers.lambdaQuery();
|
|
|
lqw.orderByDesc(CustomerInfo::getId);
|
|
lqw.orderByDesc(CustomerInfo::getId);
|
|
|
- String platformCode = PlatformContext.getPlatform();
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(platformCode) && "market".equals(platformCode)) {
|
|
|
|
|
- Long userId = LoginHelper.getLoginUser().getUserId();
|
|
|
|
|
- if (null != userId) {
|
|
|
|
|
- lqw.and(wrapper -> wrapper
|
|
|
|
|
- .eq(CustomerInfo::getCreateBy, userId)
|
|
|
|
|
- .or()
|
|
|
|
|
- .eq(CustomerInfo::getCreateBy, 1L)
|
|
|
|
|
- .or()
|
|
|
|
|
- .eq(CustomerInfo::getCreateBy, -1L)
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 数据权限过滤:只能查看自己创建的、或者是业务负责人、或者是客服支持的客户
|
|
|
|
|
+ if (bo.getCreateBy() != null || bo.getSalesPersonId() != null || bo.getServiceStaffId() != null) {
|
|
|
|
|
+ lqw.and(wrapper -> {
|
|
|
|
|
+ boolean first = true;
|
|
|
|
|
+ if (bo.getCreateBy() != null) {
|
|
|
|
|
+ if (first) {
|
|
|
|
|
+ wrapper.eq(CustomerInfo::getCreateBy, bo.getCreateBy());
|
|
|
|
|
+ first = false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.or().eq(CustomerInfo::getCreateBy, bo.getCreateBy());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (bo.getSalesPersonId() != null) {
|
|
|
|
|
+ if (first) {
|
|
|
|
|
+ wrapper.eq(CustomerInfo::getSalesPersonId, bo.getSalesPersonId());
|
|
|
|
|
+ first = false;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.or().eq(CustomerInfo::getSalesPersonId, bo.getSalesPersonId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (bo.getServiceStaffId() != null) {
|
|
|
|
|
+ if (first) {
|
|
|
|
|
+ wrapper.eq(CustomerInfo::getServiceStaffId, bo.getServiceStaffId());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ wrapper.or().eq(CustomerInfo::getServiceStaffId, bo.getServiceStaffId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getCustomerNo()), CustomerInfo::getCustomerNo, bo.getCustomerNo());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getCustomerNo()), CustomerInfo::getCustomerNo, bo.getCustomerNo());
|
|
|
lqw.eq(bo.getBelongCompanyId() != null, CustomerInfo::getBelongCompanyId, bo.getBelongCompanyId());
|
|
lqw.eq(bo.getBelongCompanyId() != null, CustomerInfo::getBelongCompanyId, bo.getBelongCompanyId());
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), CustomerInfo::getCompanyName, bo.getCompanyName());
|
|
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), CustomerInfo::getCompanyName, bo.getCompanyName());
|
|
@@ -771,8 +790,6 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getProvincialCityCounty()), CustomerInfo::getProvincialCityCounty, bo.getProvincialCityCounty());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getProvincialCityCounty()), CustomerInfo::getProvincialCityCounty, bo.getProvincialCityCounty());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), CustomerInfo::getStatus, bo.getStatus());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), CustomerInfo::getStatus, bo.getStatus());
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), CustomerInfo::getPlatformCode, bo.getPlatformCode());
|
|
lqw.eq(StringUtils.isNotBlank(bo.getPlatformCode()), CustomerInfo::getPlatformCode, bo.getPlatformCode());
|
|
|
- lqw.eq(bo.getSalesPersonId() != null, CustomerInfo::getSalesPersonId, bo.getSalesPersonId());
|
|
|
|
|
- lqw.eq(bo.getServiceStaffId() != null, CustomerInfo::getServiceStaffId, bo.getServiceStaffId());
|
|
|
|
|
lqw.eq(bo.getBelongingDepartmentId() != null, CustomerInfo::getBelongingDepartmentId, bo.getBelongingDepartmentId());
|
|
lqw.eq(bo.getBelongingDepartmentId() != null, CustomerInfo::getBelongingDepartmentId, bo.getBelongingDepartmentId());
|
|
|
Object isHighSeasObj = StringUtils.isNotBlank(bo.getIsHighSeas()) ? bo.getIsHighSeas() : bo.getParams().get("isHighSeas");
|
|
Object isHighSeasObj = StringUtils.isNotBlank(bo.getIsHighSeas()) ? bo.getIsHighSeas() : bo.getParams().get("isHighSeas");
|
|
|
String isHighSeasStr = (isHighSeasObj != null) ? StringUtils.lowerCase(String.valueOf(isHighSeasObj)) : "false";
|
|
String isHighSeasStr = (isHighSeasObj != null) ? StringUtils.lowerCase(String.valueOf(isHighSeasObj)) : "false";
|
|
@@ -907,6 +924,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
String defaultPassword = "123456";
|
|
String defaultPassword = "123456";
|
|
|
remoteUserBo.setPassword(BCrypt.hashpw(defaultPassword));
|
|
remoteUserBo.setPassword(BCrypt.hashpw(defaultPassword));
|
|
|
remoteUserBo.setUserSonType("3");
|
|
remoteUserBo.setUserSonType("3");
|
|
|
|
|
+ remoteUserBo.setRoleIds(new Long[]{contactBo.getRoleId()});
|
|
|
remoteUserBo.setTenantId(LoginHelper.getTenantId());
|
|
remoteUserBo.setTenantId(LoginHelper.getTenantId());
|
|
|
|
|
|
|
|
// 2. 调用远程服务创建用户
|
|
// 2. 调用远程服务创建用户
|
|
@@ -919,8 +937,15 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
// 3. 转换并填充业务联系人数据
|
|
// 3. 转换并填充业务联系人数据
|
|
|
CustomerContact contact = MapstructUtils.convert(contactBo, CustomerContact.class);
|
|
CustomerContact contact = MapstructUtils.convert(contactBo, CustomerContact.class);
|
|
|
contact.setCustomerId(customerId);
|
|
contact.setCustomerId(customerId);
|
|
|
- String seqId = SequenceUtils.nextPaddedIdStr(CONTACT_NO_KEY, Duration.ofDays(3650), 3);
|
|
|
|
|
- String contactNo = customerNo + seqId;
|
|
|
|
|
|
|
+ // 1. 构造带客户编号的 Key,实现“每个客户独立计数”
|
|
|
|
|
+ String seqKey = "customer_contact:contact_no:" + customerNo;
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 调用工具类
|
|
|
|
|
+ String seqId = SequenceUtils.nextPaddedIdStr(seqKey, Duration.ofDays(3650), 4);
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 拼接最终结果
|
|
|
|
|
+ String contactNo = "1" + customerNo + seqId;
|
|
|
|
|
+
|
|
|
// 建立关联
|
|
// 建立关联
|
|
|
contact.setUserId(userId);
|
|
contact.setUserId(userId);
|
|
|
contact.setContactNo(contactNo);
|
|
contact.setContactNo(contactNo);
|
|
@@ -1054,6 +1079,28 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int updateCustomerCheckStatus(Long customerId, String status) {
|
|
public int updateCustomerCheckStatus(Long customerId, String status) {
|
|
|
|
|
+ CustomerInfoVo customerInfo = baseMapper.selectVoById(customerId);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(customerInfo)) {
|
|
|
|
|
+ List<CustomerShippingAddressVo> shippingAddressVos = shippingAddressMapper.selectVoList(new LambdaQueryWrapper<CustomerShippingAddress>().eq(CustomerShippingAddress::getCustomerId, customerInfo.getId()));
|
|
|
|
|
+ if (null == shippingAddressVos || shippingAddressVos.size() == 0) {
|
|
|
|
|
+ throw new ServiceException("客户收货地址不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ CustomerSalesInfoVo salesInfoVo = customerSalesInfoMapper.selectVoOne(new LambdaQueryWrapper<CustomerSalesInfo>().eq(CustomerSalesInfo::getCustomerId, customerInfo.getId()).last("LIMIT 1"));
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(salesInfoVo)) {
|
|
|
|
|
+ if (null == salesInfoVo.getSalesPersonId()) {
|
|
|
|
|
+ throw new ServiceException("ERP销售人员业务人员不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (null == salesInfoVo.getServiceStaffId()) {
|
|
|
|
|
+ throw new ServiceException("ERP销售人员客服人员不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (null == salesInfoVo.getSettlementMethod()) {
|
|
|
|
|
+ throw new ServiceException("ERP销售人员结算方式不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (null == salesInfoVo.getCreditLevel()) {
|
|
|
|
|
+ throw new ServiceException("ERP销售人员信用等级不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
return baseMapper.update(null,
|
|
return baseMapper.update(null,
|
|
|
new LambdaUpdateWrapper<CustomerInfo>()
|
|
new LambdaUpdateWrapper<CustomerInfo>()
|
|
|
.set(CustomerInfo::getStatus, status)
|
|
.set(CustomerInfo::getStatus, status)
|
|
@@ -1391,7 +1438,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
remoteUserWechatVo.setPhoneNumber(bo.getPurchasePhone());
|
|
remoteUserWechatVo.setPhoneNumber(bo.getPurchasePhone());
|
|
|
remoteUserWechatVo.setNickname(bo.getPurchaseName());
|
|
remoteUserWechatVo.setNickname(bo.getPurchaseName());
|
|
|
remoteUserWechatService.insertUserWechat(remoteUserWechatVo);
|
|
remoteUserWechatService.insertUserWechat(remoteUserWechatVo);
|
|
|
- }else if ("3".equals(bo.getRegisterSource())){
|
|
|
|
|
|
|
+ } else if ("3".equals(bo.getRegisterSource())) {
|
|
|
RemoteUserWechatVo remoteUserWechatVo = new RemoteUserWechatVo();
|
|
RemoteUserWechatVo remoteUserWechatVo = new RemoteUserWechatVo();
|
|
|
remoteUserWechatVo.setGzhOpenId(bo.getOpenId());
|
|
remoteUserWechatVo.setGzhOpenId(bo.getOpenId());
|
|
|
remoteUserWechatVo.setUserId(userId);
|
|
remoteUserWechatVo.setUserId(userId);
|
|
@@ -1504,9 +1551,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (salesPersonId == null || deptId == null) {
|
|
|
|
|
- log.warn("转移业务人员失败,业务人员 ID 或部门 ID 为空");
|
|
|
|
|
- throw new ServiceException("业务人员和所属部门不能为空");
|
|
|
|
|
|
|
+ if (salesPersonId == null ) {
|
|
|
|
|
+ log.warn("转移业务人员失败,业务人员 ID 为空");
|
|
|
|
|
+ throw new ServiceException("业务人员不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|