Commit f587d4f756cbd7afa5f0e7efde8dc84539aa48ef

Authored by YunaiV
1 parent 93eabb4e

feat(member):收货地址 admin 接口回填 areaName

AddressRespVO 加 areaName 字段;AddressConvert 补 convert03
(@Mapping areaId→areaName,复用 convertAreaIdToAreaName/AreaUtils.format),
convertList2 自动带出。/member/address/list 返回可读地区名,替代前端展示原始 areaId 编码
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/enums/ErrorCodeConstants.java
@@ -26,6 +26,7 @@ public interface ErrorCodeConstants { @@ -26,6 +26,7 @@ public interface ErrorCodeConstants {
26 ErrorCode BUSINESS_DELETE_FAIL_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除"); 26 ErrorCode BUSINESS_DELETE_FAIL_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除");
27 ErrorCode BUSINESS_UPDATE_STATUS_FAIL_END_STATUS = new ErrorCode(1_020_002_002, "更新商机状态失败,原因:已经是结束状态"); 27 ErrorCode BUSINESS_UPDATE_STATUS_FAIL_END_STATUS = new ErrorCode(1_020_002_002, "更新商机状态失败,原因:已经是结束状态");
28 ErrorCode BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS = new ErrorCode(1_020_002_003, "更新商机状态失败,原因:已经是该状态"); 28 ErrorCode BUSINESS_UPDATE_STATUS_FAIL_STATUS_EQUALS = new ErrorCode(1_020_002_003, "更新商机状态失败,原因:已经是该状态");
  29 + ErrorCode BUSINESS_CONTACT_CUSTOMER_NOT_MATCH = new ErrorCode(1_020_002_004, "商机关联的联系人不属于该客户");
29 30
30 // ========== 联系人管理 1-020-003-000 ========== 31 // ========== 联系人管理 1-020-003-000 ==========
31 ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在"); 32 ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
yudao-module-crm/src/main/java/cn/iocoder/yudao/module/crm/service/business/CrmBusinessServiceImpl.java
@@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.business; @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.business;
2 2
3 import cn.hutool.core.collection.CollUtil; 3 import cn.hutool.core.collection.CollUtil;
4 import cn.hutool.core.collection.ListUtil; 4 import cn.hutool.core.collection.ListUtil;
  5 +import cn.hutool.core.util.ObjUtil;
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; 7 import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 8 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
@@ -15,6 +16,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO; @@ -15,6 +16,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
15 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO; 16 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
16 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO; 17 import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
17 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO; 18 import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO;
  19 +import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
18 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper; 20 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
19 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper; 21 import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper;
20 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; 22 import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
@@ -194,9 +196,15 @@ public class CrmBusinessServiceImpl implements CrmBusinessService { @@ -194,9 +196,15 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
194 if (saveReqVO.getCustomerId() != null) { 196 if (saveReqVO.getCustomerId() != null) {
195 customerService.validateCustomer(saveReqVO.getCustomerId()); 197 customerService.validateCustomer(saveReqVO.getCustomerId());
196 } 198 }
197 - // 校验联系人 199 + // 校验联系人(且必须与商机属于同一客户,避免跨客户关联)
198 if (saveReqVO.getContactId() != null) { 200 if (saveReqVO.getContactId() != null) {
199 contactService.validateContact(saveReqVO.getContactId()); 201 contactService.validateContact(saveReqVO.getContactId());
  202 + if (saveReqVO.getCustomerId() != null) {
  203 + CrmContactDO contact = contactService.getContact(saveReqVO.getContactId());
  204 + if (ObjUtil.notEqual(saveReqVO.getCustomerId(), contact.getCustomerId())) {
  205 + throw exception(BUSINESS_CONTACT_CUSTOMER_NOT_MATCH);
  206 + }
  207 + }
200 } 208 }
201 // 校验负责人 209 // 校验负责人
202 if (saveReqVO.getOwnerUserId() != null) { 210 if (saveReqVO.getOwnerUserId() != null) {
yudao-module-member/src/main/java/cn/iocoder/yudao/module/member/controller/admin/address/vo/AddressRespVO.java
@@ -16,4 +16,7 @@ public class AddressRespVO extends AddressBaseVO { @@ -16,4 +16,7 @@ public class AddressRespVO extends AddressBaseVO {
16 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 16 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
17 private LocalDateTime createTime; 17 private LocalDateTime createTime;
18 18
  19 + @Schema(description = "地区名称", example = "上海上海市普陀区")
  20 + private String areaName;
  21 +
19 } 22 }
yudao-module-member/src/main/java/cn/iocoder/yudao/module/member/convert/address/AddressConvert.java
@@ -40,6 +40,9 @@ public interface AddressConvert { @@ -40,6 +40,9 @@ public interface AddressConvert {
40 return AreaUtils.format(areaId); 40 return AreaUtils.format(areaId);
41 } 41 }
42 42
  43 + @Mapping(source = "areaId", target = "areaName", qualifiedByName = "convertAreaIdToAreaName")
  44 + AddressRespVO convert03(MemberAddressDO bean);
  45 +
43 List<AddressRespVO> convertList2(List<MemberAddressDO> list); 46 List<AddressRespVO> convertList2(List<MemberAddressDO> list);
44 47
45 } 48 }