|
@@ -16,6 +16,7 @@ import org.dromara.common.core.enums.IsDefault;
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
import org.dromara.common.core.utils.DateUtils;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
|
|
+import org.dromara.common.core.utils.ObjectUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
@@ -122,7 +123,9 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
vo.setCustomerSalesInfoVo(null);
|
|
vo.setCustomerSalesInfoVo(null);
|
|
|
return vo;
|
|
return vo;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(customerSalesInfo.getCreditAmount()) && ObjectUtils.isNotEmpty(customerSalesInfo.getTemporaryQuota())) {
|
|
|
|
|
+ customerSalesInfo.setRemainingQuota(customerSalesInfo.getCreditAmount().add(customerSalesInfo.getTemporaryQuota()));
|
|
|
|
|
+ }
|
|
|
Set<Long> staffIds = new HashSet<>();
|
|
Set<Long> staffIds = new HashSet<>();
|
|
|
Set<Long> deptIds = new HashSet<>();
|
|
Set<Long> deptIds = new HashSet<>();
|
|
|
|
|
|
|
@@ -540,7 +543,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
// 1. 提前校验名称是否存在 (核心修改点)
|
|
// 1. 提前校验名称是否存在 (核心修改点)
|
|
|
String customerName = bo.getCustomerName();
|
|
String customerName = bo.getCustomerName();
|
|
|
if (customerName == null || customerName.trim().isEmpty()) {
|
|
if (customerName == null || customerName.trim().isEmpty()) {
|
|
|
- throw new IllegalArgumentException("客户名称不能为空");
|
|
|
|
|
|
|
+ throw new ServiceException("客户名称不能为空");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 构造查询条件
|
|
// 构造查询条件
|
|
@@ -556,7 +559,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
// --- 新增场景 ---
|
|
// --- 新增场景 ---
|
|
|
if (existingCustomer != null) {
|
|
if (existingCustomer != null) {
|
|
|
// 数据库中已存在同名用户
|
|
// 数据库中已存在同名用户
|
|
|
- throw new IllegalArgumentException("该客户已存在,请勿重复添加");
|
|
|
|
|
|
|
+ throw new ServiceException("该客户已存在,请勿重复添加");
|
|
|
}
|
|
}
|
|
|
// 不存在,继续执行插入
|
|
// 不存在,继续执行插入
|
|
|
entity = MapstructUtils.convert(bo, CustomerInfo.class);
|
|
entity = MapstructUtils.convert(bo, CustomerInfo.class);
|
|
@@ -564,14 +567,15 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
int insertResult = baseMapper.insert(entity);
|
|
int insertResult = baseMapper.insert(entity);
|
|
|
if (insertResult > 0) {
|
|
if (insertResult > 0) {
|
|
|
bo.setId(entity.getId()); // 回填ID
|
|
bo.setId(entity.getId()); // 回填ID
|
|
|
- return true;
|
|
|
|
|
} else {
|
|
} else {
|
|
|
- return false;
|
|
|
|
|
|
|
+ throw new ServiceException("新增客户信息失败");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
Long customerId = entity.getId();
|
|
Long customerId = entity.getId();
|
|
|
|
|
|
|
|
|
|
+ String customerNo = entity.getCustomerNo();
|
|
|
|
|
+
|
|
|
/*新增客户时给每个客户创建自己的组织架构*/
|
|
/*新增客户时给每个客户创建自己的组织架构*/
|
|
|
RemoteDeptVo remoteDeptVo = new RemoteDeptVo();
|
|
RemoteDeptVo remoteDeptVo = new RemoteDeptVo();
|
|
|
remoteDeptVo.setParentId(100L);
|
|
remoteDeptVo.setParentId(100L);
|
|
@@ -615,6 +619,7 @@ public class CustomerInfoServiceImpl extends ServiceImpl<CustomerInfoMapper, Cus
|
|
|
|
|
|
|
|
// 销售信息
|
|
// 销售信息
|
|
|
if (salesBo != null) {
|
|
if (salesBo != null) {
|
|
|
|
|
+ salesBo.setRemainingQuota(salesBo.getCreditAmount());
|
|
|
CustomerSalesInfo salesEntity = MapstructUtils.convert(salesBo, CustomerSalesInfo.class);
|
|
CustomerSalesInfo salesEntity = MapstructUtils.convert(salesBo, CustomerSalesInfo.class);
|
|
|
salesEntity.setCustomerId(customerId);
|
|
salesEntity.setCustomerId(customerId);
|
|
|
customerSalesInfoMapper.insert(salesEntity);
|
|
customerSalesInfoMapper.insert(salesEntity);
|
|
@@ -642,10 +647,11 @@ 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;
|
|
|
// 建立关联
|
|
// 建立关联
|
|
|
contact.setUserId(userId);
|
|
contact.setUserId(userId);
|
|
|
-
|
|
|
|
|
|
|
+ contact.setContactNo(contactNo);
|
|
|
// 4. 插入联系人表
|
|
// 4. 插入联系人表
|
|
|
if (customerContactMapper.insert(contact) <= 0) {
|
|
if (customerContactMapper.insert(contact) <= 0) {
|
|
|
throw new ServiceException("保存联系人信息失败");
|
|
throw new ServiceException("保存联系人信息失败");
|