|
|
|
@@ -7,6 +7,8 @@ import com.imyeyu.api.modules.common.vo.attach.BizUpdateReq;
|
|
|
|
|
import com.imyeyu.api.modules.gao.entity.GaoCustomer;
|
|
|
|
|
import com.imyeyu.api.modules.gao.mapper.GaoCustomerMapper;
|
|
|
|
|
import com.imyeyu.api.modules.gao.service.GaoCustomerService;
|
|
|
|
|
import com.imyeyu.api.modules.user.service.UserLoginService;
|
|
|
|
|
import com.imyeyu.api.modules.user.service.UserService;
|
|
|
|
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerDailyStatView;
|
|
|
|
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerInviteUpdateReq;
|
|
|
|
|
import com.imyeyu.api.modules.gao.vo.GaoCustomerSearchReq;
|
|
|
|
@@ -54,6 +56,8 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|
|
|
|
|
|
|
|
|
private final GaoCustomerMapper mapper;
|
|
|
|
|
private final AttachmentService attachmentService;
|
|
|
|
|
private final UserLoginService userLoginService;
|
|
|
|
|
private final UserService userService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected BaseMapper<GaoCustomer, String> mapper() {
|
|
|
|
@@ -63,6 +67,7 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|
|
|
|
@Override
|
|
|
|
|
public void create(GaoCustomer entity) {
|
|
|
|
|
checkEntity(entity, false);
|
|
|
|
|
entity.setCreatorUserId(userLoginService.getRequireLoginUserId());
|
|
|
|
|
super.create(entity);
|
|
|
|
|
saveAttachment(entity.getId(), resolveAttachmentList(entity));
|
|
|
|
|
loadTransient(entity);
|
|
|
|
@@ -254,19 +259,22 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|
|
|
|
|
|
|
|
|
private void checkEntity(GaoCustomer entity, boolean requireId) {
|
|
|
|
|
TimiException.required(entity, "not found customer");
|
|
|
|
|
GaoCustomer dbCustomer;
|
|
|
|
|
if (requireId) {
|
|
|
|
|
TimiException.required(entity.getId(), "not found customer.id");
|
|
|
|
|
dbCustomer = super.get(entity.getId());
|
|
|
|
|
entity.setCreatorUserId(dbCustomer.getCreatorUserId());
|
|
|
|
|
}
|
|
|
|
|
TimiException.required(entity.getName(), "not found customer.name");
|
|
|
|
|
entity.setName(entity.getName().trim());
|
|
|
|
|
TimiException.requiredTrue(!entity.getName().isEmpty(), "not found customer.name");
|
|
|
|
|
GaoCustomer dbCustomer = mapper.selectByName(entity.getName());
|
|
|
|
|
if (dbCustomer != null && !dbCustomer.getId().equals(entity.getId())) {
|
|
|
|
|
GaoCustomer duplicateCustomer = mapper.selectByName(entity.getName());
|
|
|
|
|
if (duplicateCustomer != null && !duplicateCustomer.getId().equals(entity.getId())) {
|
|
|
|
|
throw new TimiException(TimiCode.ARG_BAD, "客户姓名已存在");
|
|
|
|
|
}
|
|
|
|
|
if (TimiJava.isNotEmpty(entity.getCode())) {
|
|
|
|
|
dbCustomer = mapper.selectByCode(entity.getCode());
|
|
|
|
|
if (dbCustomer != null && !dbCustomer.getId().equals(entity.getId())) {
|
|
|
|
|
duplicateCustomer = mapper.selectByCode(entity.getCode());
|
|
|
|
|
if (duplicateCustomer != null && !duplicateCustomer.getId().equals(entity.getId())) {
|
|
|
|
|
throw new TimiException(TimiCode.ARG_BAD, "客户编码已存在");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@@ -283,6 +291,9 @@ public class GaoCustomerServiceImplement extends AbstractEntityService<GaoCustom
|
|
|
|
|
if (TimiJava.isNotEmpty(customer.getIntroducerCustomerId())) {
|
|
|
|
|
customer.setIntroducerCustomer(super.get(customer.getIntroducerCustomerId()));
|
|
|
|
|
}
|
|
|
|
|
if (TimiJava.isNotEmpty(customer.getCreatorUserId())) {
|
|
|
|
|
customer.setCreatorUser(userService.get(customer.getCreatorUserId()));
|
|
|
|
|
}
|
|
|
|
|
customer.setInvitedCount(mapper.countInvited(customer.getId()));
|
|
|
|
|
customer.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.GAO_CUSTOMER, customer.getId(), GaoCustomer.AttachType.PHOTO.name()));
|
|
|
|
|
}
|
|
|
|
|