|
|
|
@ -42,24 +42,6 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat |
|
|
|
@Autowired |
|
|
|
private CustomerAddressMapper customerAddressMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 获取客户主联系人对象 |
|
|
|
* @author: fengyuan_yang |
|
|
|
* @date: 2023/9/1 14:03 |
|
|
|
* @param: [data] |
|
|
|
* @return: com.spring.modules.customer.entity.CustomerContactEntity |
|
|
|
**/ |
|
|
|
public CustomerContactEntity getCustomerContactData(CustomerInformationVo data){ |
|
|
|
CustomerContactEntity customerContactEntity = new CustomerContactEntity(); |
|
|
|
customerContactEntity.setSite(data.getSite()); |
|
|
|
customerContactEntity.setCustomerNo(data.getCustomerNo()); |
|
|
|
customerContactEntity.setContactName(data.getContactName()); |
|
|
|
customerContactEntity.setContactPhoneNumber1(data.getContactPhoneNumber1()); |
|
|
|
customerContactEntity.setPrimaryContact(data.getPrimaryContact()); |
|
|
|
customerContactEntity.setContactStatus(data.getContactStatus()); |
|
|
|
return customerContactEntity; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 客户信息列表 |
|
|
|
* @author: fengyuan_yang |
|
|
|
@ -94,9 +76,9 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat |
|
|
|
CustomerAddressEntity customerAddressData = new CustomerAddressEntity(); |
|
|
|
customerAddressData.setSite(data.getSite()); |
|
|
|
customerAddressData.setCustomerNo(data.getCustomerNo()); |
|
|
|
customerAddressData.setPrimaryAddress("Y"); |
|
|
|
customerAddressData.setAddressStatus("启用"); |
|
|
|
customerAddressData.setAddressType("类型1"); |
|
|
|
customerAddressData.setPrimaryAddress(data.getPrimaryAddress()); |
|
|
|
customerAddressData.setAddressStatus(data.getAddressStatus()); |
|
|
|
customerAddressData.setAddressType(data.getAddressType()); |
|
|
|
customerAddressMapper.insert(customerAddressData); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -116,16 +98,43 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat |
|
|
|
updateInformationWrapper.eq("site", data.getSite()); |
|
|
|
updateInformationWrapper.eq("customer_no", data.getCustomerNo()); |
|
|
|
customerInformationMapper.update(data, updateInformationWrapper); |
|
|
|
// 编辑客户主联系人 |
|
|
|
CustomerContactEntity customerContactData = getCustomerContactData(data); |
|
|
|
customerContactData.setUpdateBy(data.getUpdateBy()); |
|
|
|
UpdateWrapper<CustomerContactEntity> updateContactWrapper = new UpdateWrapper<>(); |
|
|
|
updateContactWrapper.eq("site", data.getSite()); |
|
|
|
updateContactWrapper.eq("customer_no", data.getCustomerNo()); |
|
|
|
updateContactWrapper.eq("primary_contact", data.getPrimaryContact()); |
|
|
|
customerContactMapper.update(customerContactData, updateContactWrapper); |
|
|
|
// 编辑主联系地址 |
|
|
|
|
|
|
|
// 1. 编辑客户主联系人 |
|
|
|
// 1.1 判断联系人姓名是否修改 |
|
|
|
Map<String,Object> columnMap = new HashMap<>(); |
|
|
|
columnMap.put("site", data.getSite()); |
|
|
|
columnMap.put("customer_no", data.getCustomerNo()); |
|
|
|
columnMap.put("primary_contact", data.getPrimaryContact()); |
|
|
|
List<CustomerContactEntity> contactList = customerContactMapper.selectByMap(columnMap); |
|
|
|
if (contactList.size() > 0 && contactList.get(0) != null && StringUtils.isNotBlank(data.getContactName())) { |
|
|
|
// 1.2 修改主联系人 |
|
|
|
if (!contactList.get(0).getContactName().equals(data.getContactName())) { |
|
|
|
CustomerContactEntity customerContactData = getCustomerContactData(data); |
|
|
|
customerContactData.setUpdateBy(data.getUpdateBy()); |
|
|
|
UpdateWrapper<CustomerContactEntity> updateContactWrapper = new UpdateWrapper<>(); |
|
|
|
updateContactWrapper.eq("site", data.getSite()); |
|
|
|
updateContactWrapper.eq("customer_no", data.getCustomerNo()); |
|
|
|
updateContactWrapper.eq("primary_contact", data.getPrimaryContact()); |
|
|
|
customerContactMapper.update(customerContactData, updateContactWrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
// 2. 编辑主联系地址 |
|
|
|
// 2.1 判断联系地址姓名是否修改 |
|
|
|
columnMap.remove("primary_contact"); |
|
|
|
columnMap.put("primary_address", "Y"); |
|
|
|
List<CustomerAddressEntity> addressList = customerAddressMapper.selectByMap(columnMap); |
|
|
|
if (addressList.size() > 0 && addressList.get(0) != null && StringUtils.isNotBlank(data.getAddressName())) { |
|
|
|
// 2.2 修改主联系地址 |
|
|
|
if (!addressList.get(0).getAddressName().equals(data.getAddressName())) { |
|
|
|
CustomerAddressEntity customerAddressData = new CustomerAddressEntity(); |
|
|
|
customerAddressData.setUpdateBy(data.getUpdateBy()); |
|
|
|
customerAddressData.setAddressName(data.getAddressName()); |
|
|
|
UpdateWrapper<CustomerAddressEntity> updateAddressWrapper = new UpdateWrapper<>(); |
|
|
|
updateAddressWrapper.eq("site", data.getSite()); |
|
|
|
updateAddressWrapper.eq("customer_no", data.getCustomerNo()); |
|
|
|
updateAddressWrapper.eq("primary_address", data.getPrimaryAddress()); |
|
|
|
customerAddressMapper.update(customerAddressData, updateAddressWrapper); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -149,4 +158,22 @@ public class CustomerInformationServiceImpl extends ServiceImpl<CustomerInformat |
|
|
|
customerContactMapper.deleteByMap(map); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @description: 获取客户主联系人对象 |
|
|
|
* @author: fengyuan_yang |
|
|
|
* @date: 2023/9/1 14:03 |
|
|
|
* @param: [data] |
|
|
|
* @return: com.spring.modules.customer.entity.CustomerContactEntity |
|
|
|
**/ |
|
|
|
public CustomerContactEntity getCustomerContactData(CustomerInformationVo data){ |
|
|
|
CustomerContactEntity customerContactEntity = new CustomerContactEntity(); |
|
|
|
customerContactEntity.setSite(data.getSite()); |
|
|
|
customerContactEntity.setCustomerNo(data.getCustomerNo()); |
|
|
|
customerContactEntity.setContactName(data.getContactName()); |
|
|
|
customerContactEntity.setContactPhoneNumber1(data.getContactPhoneNumber1()); |
|
|
|
customerContactEntity.setPrimaryContact(data.getPrimaryContact()); |
|
|
|
customerContactEntity.setContactStatus(data.getContactStatus()); |
|
|
|
return customerContactEntity; |
|
|
|
} |
|
|
|
} |