Commit 809ce1b2 authored by yanghao's avatar yanghao

Merge branch 'release-fix' into release

parents 41793083 26c696cf
......@@ -122,7 +122,7 @@ public interface CustomerComplaintMapper extends BaseMapperX<CustomerComplaintDO
"</script>"
})
List<CustomerComplaintExcelVO> selectList(@Param("query") CustomerComplaintExportReqVO query);
List<CustomerComplaintExcelVO> selectExcelList(@Param("query") CustomerComplaintExportReqVO query);
}
......@@ -25,13 +25,13 @@ import java.util.List;
public interface CustomerMapper extends BaseMapperX<CustomerDO> {
//合并操作日志
void doMergeCustomerOperateLog(long customer_id1,long customer_id2);
void doMergeCustomerOperateLog(@Param("customer_id1") Long customer_id1, @Param("customer_id2") Long customer_id2);
//合并客户信用日志
void doMergeCustomerCreditLog(long customer_id1,long customer_id2);
void doMergeCustomerCreditLog(@Param("customer_id1") Long customer_id1, @Param("customer_id2") Long customer_id2);
//合并客户登记日志
void doMergeCustomerLevelLog(long customer_id1,long customer_id2);
void doMergeCustomerLevelLog(@Param("customer_id1") Long customer_id1, @Param("customer_id2") Long customer_id2);
IPage<CustomerDO> getPage(IPage<CustomerDO> page,
@Param(Constants.WRAPPER) Wrapper<CustomerDO> queryWrapper);
......
......@@ -131,7 +131,7 @@ public class CustomerComplaintServiceImpl extends AbstractService<CustomerCompla
@Override
public List<CustomerComplaintExcelVO> getCustomerComplaintList(CustomerComplaintExportReqVO exportReqVO) {
return customerComplaintMapper.selectList(exportReqVO);
return customerComplaintMapper.selectExcelList(exportReqVO);
}
}
......@@ -15,7 +15,7 @@ Content-Type: application/json
### 合并客户
GET {{baseUrl}}/ecw/customer/mergeCus?customerIdSaved=52009&customerIdDeleted=51966
GET {{baseUrl}}/ecw/customer/mergeCus?customerIdSaved=52043&customerIdDeleted=52042
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
Content-Type: application/json
......
......@@ -89,6 +89,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -117,6 +118,9 @@ public class CustomerController {
@Resource
private CustomerService customerService;
@Resource
private CustomerMergeService customerMergeService;
@Resource
private CustomerBankService customerBankService;
......@@ -126,9 +130,6 @@ public class CustomerController {
@Resource
private AdminUserApi adminUserApi;
@Resource
private OrderApi orderApi;
@Resource
private CountryService countryService;
......@@ -151,12 +152,6 @@ public class CustomerController {
private ParamValidatorService paramValidatorService;
@Resource
private InternalMessageService internalMessageService;
@Resource
private CustomerLevelService customerLevelService;
@Resource
private CustomerCreditService customerCreditService;
@Resource
private ParamValidatorApi paramValidatorApi;
......@@ -167,38 +162,8 @@ public class CustomerController {
@Resource
CustomerDetailMapper customerDetailMapper;
@Resource
OfferService offerService;
//客户跟进
@Resource
CustomerFollowService customerFollowService;
@Resource
private CustomerComplaintService customerComplaintService;
@Resource
private ReceiptServiceImpl receiptService;
@Resource
private ProductBrandEmpowerServiceImpl productBrandEmpowerService;
//客户登记日志
@Resource
private CustomerLevelLogServiceImpl customerLevelLogService;
@Resource
private CustomerOperateLogService customerOperateLogService;
@Resource
private TargetLogService targetLogService;
@Resource
private CommissionPayableService commissionPayableService;
@Resource
private CommissionPaymentService commissionPaymentService;
public CustomerController() {
}
......@@ -400,6 +365,7 @@ public class CustomerController {
@GetMapping("/mergeCus")
@ApiOperation("合并客户信息")
@Transactional(rollbackFor = Exception.class)
public CommonResult<Boolean> mergeCus(
@Valid CustomerMerge par) {
//1. 保留客户和非主客户,不能在两个不同的客户经理名下,
......@@ -409,278 +375,33 @@ public class CustomerController {
// 客户投诉,品牌授权都迁移到保留客户中,其他信息不会迁移,
// 如需要维护非主客户的客户档案信息到保留客户中,请先维护好再操作
CustomerDO customerDO1 = customerService.getById(par.getCustomerIdSaved());
if (customerDO1 == null) {
CustomerDO customerDOSaved = customerService.getById(par.getCustomerIdSaved());
if (customerDOSaved == null) {
throw exception(ErrorCodeConstants.CUSTOMER_SAVED_NOT_EXISTS);
}
if (customerDO1.getCustomerService() == null) {
if (customerDOSaved.getCustomerService() == null) {
throw exception(ErrorCodeConstants.CUSTOMER_SAVED_CUSTOMER_SERVICE_IS_NULL);
}
CustomerDO customerDO2 = customerService.getById(par.getCustomerIdDeleted());
if (customerDO2 == null) {
CustomerDO customerDODeleted = customerService.getById(par.getCustomerIdDeleted());
if (customerDODeleted == null) {
throw exception(ErrorCodeConstants.CUSTOMER_DELETED_NOT_EXISTS);
}
if (customerDO2.getCustomerService() == null) {
if (customerDODeleted.getCustomerService() == null) {
throw exception(ErrorCodeConstants.CUSTOMER_DELETED_CUSTOMER_SERVICE_IS_NULL);
}
if (customerDO1.getCustomerService() != customerDO2.getCustomerService()) {
if (customerDOSaved.getCustomerService() != customerDODeleted.getCustomerService()) {
throw exception(ErrorCodeConstants.CUSTOMER_MERGE_CUSTOMER_SERVICE_NOT_SAME);
}
// 验证非主客户是否有客户业务审批中
customerService.validateCustomerApproval(customerDO2);
customerService.validateCustomerApproval(customerDODeleted);
boolean merge = doMergeCus(customerDO1, customerDO2, SecurityFrameworkUtils.getLoginUserId());
boolean merge = customerMergeService.doMergeCus(customerDOSaved, customerDODeleted, SecurityFrameworkUtils.getLoginUserId());
return success(merge);
}
private boolean doMergeCus(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId) {
/*
提交验证:
当保留客户和非主客户的客户经理均不为空且不是同一个用户(允许客户在公海),
弹出提示:保留客户和非主客户,不能在两个不同的客户经理名下,
请先确认两个客户在同一个客户经理名下,不允许提交
当非主客户/保留客户在移交过程中,不允许合并,弹出提示
当允许提交,先弹出上面的注意事项提示,确认后提交
1. 非主客户中的客户联系人所有信息追加到保留客户中,注意:关联账号也需要一并追加
2. 非主客户中的所有关联订单中的客户编号需要更新为保留客户,业绩归属为非主客户,
也需要同时更新为保留客户(此处需要注意有一些订单的收发货人是同一个客户,
还需要注意控货订单的情况,控货权)
3. 非主客户的跟进记录,报价单,客户投诉,品牌授权,
财务相关单据(收款单,佣金请款单,佣金付款单),都需要更新为保留客户
4. 非主客户关联的注册会员信息
4. 提交成功后,非主客户删除,插入记录到保留客户,
备注:客户合并,删除XXX非主客户编号
注意:此处要求是在保留客户中能查询到非主客户的所有信息,
不清楚数据库逻辑结构,此处需要开发查找出所有的关联关系
非主客户关联的订单/收款单/佣金情况单,佣金付款单有在途流程,
需要测试这种情况是否影响合并
*/
//合并订单 在合并订单前会验证非主客户是否有审批中的订单,若存在则不能合并抛出异常
orderApi.mergeOrder(customerDO1.getId(), customerDO2.getId());
//把客户2的联系方式合并到客户1 1
doMogeContact(customerDO1, customerDO2, loginUserId);
//合并报价单 2
doMogeOffer(customerDO1, customerDO2, loginUserId);
//合并跟进记录 3
doMergeCustomerFollow(customerDO1, customerDO2, loginUserId);
//合并客户投诉 4
doMergeCustomerComplaint(customerDO1, customerDO2, loginUserId);
//合并产品品牌授权 6
doMergeProductBrandEmpower(customerDO1,customerDO2,loginUserId);
//合并客户登记日志 7
doMergeCustomerLevelLog(customerDO1,customerDO2,loginUserId);
//合并信用日志 8
customerService.doMergeCustomerCreditLog(customerDO1.getId(),
customerDO2.getId());
//合并操作日志 9
// customerService.doMergeCustomerOperateLog(customerDO1.getId(),
// customerDO2.getId());
//合并收款单信息 5
doMergeeReceipt(customerDO1, customerDO2, loginUserId);
// 合并订单佣金应付款
doMergeComissionPayable(customerDO1, customerDO2);
// 合并佣金付款单
doMergeCommissionPayment(customerDO1, customerDO2);
// 合并业绩
doMergeTargetLog(customerDO1, customerDO2);
// 纪录客户合并日志
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
CustomerOperateLogCreateReqVO customerOperateLogCreateReqVO = new CustomerOperateLogCreateReqVO()
.setOperator(loginUser == null ? null : loginUser.getId())
.setOperatorName(loginUser == null ? null : loginUser.getNickname())
.setCustomerId(customerDO1.getId())
.setNumber(customerDO1.getNumber())
.setName(customerDO1.getName())
.setOldCustomerService(null)
.setNewCustomerService(customerDO1.getCustomerService())
.setOldEstimateEnterOpenSeaTime(null)
.setNewEstimateEnterOpenSeaTime(customerDO1.getEstimateEnterOpenSeaTime())
.setOrderId(null)
.setOrderNo(null)
.setOperateType(CustomerOperateTypeEnum.CUSTOMER_MERGE.getValue())
.setRemark(String.format("客户合并,删除非主客户【%d-%s-%s】", customerDO2.getId(), customerDO2.getNumber(), customerDO2.getName()));
customerOperateLogService.createOperateLog(customerOperateLogCreateReqVO);
//纪录被删除的客户的日志
CustomerOperateLogCreateReqVO customerOperateLogCreateReqVO2 = new CustomerOperateLogCreateReqVO()
.setOperator(loginUser == null ? null : loginUser.getId())
.setOperatorName(loginUser == null ? null : loginUser.getNickname())
.setCustomerId(customerDO2.getId())
.setNumber(customerDO2.getNumber())
.setName(customerDO2.getName())
.setOldCustomerService(null)
.setNewCustomerService(customerDO2.getCustomerService())
.setOldEstimateEnterOpenSeaTime(null)
.setNewEstimateEnterOpenSeaTime(customerDO2.getEstimateEnterOpenSeaTime())
.setOrderId(null)
.setOrderNo(null)
.setOperateType(CustomerOperateTypeEnum.CUSTOMER_MERGE.getValue())
.setRemark(String.format("客户合并,将此客户合并到主客户【%d-%s-%s】", customerDO1.getId(), customerDO1.getNumber(), customerDO1.getName()));
customerOperateLogService.createOperateLog(customerOperateLogCreateReqVO2);
return true;
}
private void doMergeCommissionPayment(CustomerDO customerDO1, CustomerDO customerDO2) {
commissionPaymentService.update(new LambdaUpdateWrapper<CommissionPaymentDO>()
.set(CommissionPaymentDO::getCustomerId, customerDO1.getId())
.set(CommissionPaymentDO::getCustomerName, customerDO1.getName())
.eq(CommissionPaymentDO::getCustomerId, customerDO2.getId()));
}
private void doMergeTargetLog(CustomerDO customerDO1, CustomerDO customerDO2) {
targetLogService.update(new LambdaUpdateWrapper<TargetLogDO>()
.set(TargetLogDO::getCustomerId, customerDO1.getId())
.set(TargetLogDO::getCustomerType, customerDO1.getType())
.eq(TargetLogDO::getCustomerId, customerDO2.getId()));
}
private void doMergeComissionPayable(CustomerDO customerDO1, CustomerDO customerDO2) {
commissionPayableService.update(new LambdaUpdateWrapper<CommissionPayableDO>()
.set(CommissionPayableDO::getCustomerId, customerDO1.getId())
.set(CommissionPayableDO::getCustomerName, customerDO1.getName())
.eq(CommissionPayableDO::getCustomerId, customerDO2.getId()));
}
//合并客户信用日志
private void doMergeCustomerLevelLog(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId)
{
customerService.doMergeCustomerLevelLog(customerDO1.getId(),
customerDO2.getId());
}
//合并产品品牌授权
private void doMergeProductBrandEmpower(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId)
{
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<ProductBrandEmpowerDO>().
eq(ProductBrandEmpowerDO::getCustomerId,
customerDO2.getId());
List<ProductBrandEmpowerDO> list =
productBrandEmpowerService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (ProductBrandEmpowerDO d : list
) {
d.setCustomerId(customerDO1.getId());
productBrandEmpowerService.updateById(d);
}
}
private void doMergeCustomerComplaint(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerComplaintDO>().
eq(CustomerComplaintDO::getCustomerId,
customerDO2.getId());
List<CustomerComplaintDO> list =
customerComplaintService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (CustomerComplaintDO d : list
) {
d.setCustomerId(customerDO1.getId());
customerComplaintService.updateById(d);
}
}
//合并收款单
private void doMergeeReceipt(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<ReceiptDO>().
eq(ReceiptDO::getCustomerId, customerDO2.getId());
List<ReceiptDO> list = receiptService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (ReceiptDO d : list
) {
d.setCustomerId(customerDO1.getId());
receiptService.updateById(d);
}
}
//合并客户跟进
private void doMergeCustomerFollow(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerFollowDO>().
eq(CustomerFollowDO::getCustomerId, customerDO2.getId());
List<CustomerFollowDO> list = customerFollowService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (CustomerFollowDO d : list
) {
d.setCustomerId(customerDO1.getId());
customerFollowService.updateById(d);
}
}
//合并报价单
private void doMogeOffer(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<OfferDO>().
eq(OfferDO::getRelationId, customerDO2.getId());
List<OfferDO> list = offerService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (OfferDO o : list
) {
o.setRelationId(customerDO1.getId());
o.setUpdateTime(new Date());
offerService.updateById(o);
}
}
//合并联系人
private void doMogeContact(CustomerDO customerDO1,
CustomerDO customerDO2,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerContactsDO>().
eq(CustomerContactsDO::getCustomerId, customerDO2.getId());
List<CustomerContactsDO> cuscontactList2 =
customerContactsService.selectList(q2);
if (CollectionUtil.isNotEmpty(cuscontactList2)) {
for (CustomerContactsDO d : cuscontactList2
) {
d.setCustomerId(customerDO1.getId());
//被合并的客户联系人,默认为非默认
d.setIsDefault(0);
d.setUpdateTime(new Date());
d.setUpdater(String.valueOf(loginUserId));
customerContactsService.updateById(d);
}
}
}
@GetMapping("/get")
@ApiOperation("获得客户详情")
......
package cn.iocoder.yudao.module.customer.controller.admin.customer;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
public interface CustomerMergeService {
boolean doMergeCus(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId);
}
package cn.iocoder.yudao.module.customer.controller.admin.customer;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.boot.module.order.api.OrderApi;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.CustomerDO;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.complaint.CustomerComplaintDO;
import cn.iocoder.yudao.module.customer.dal.dataobject.customer.follow.CustomerFollowDO;
import cn.iocoder.yudao.module.customer.dal.dataobject.customerContacts.CustomerContactsDO;
import cn.iocoder.yudao.module.customer.service.customer.CustomerService;
import cn.iocoder.yudao.module.customer.service.customer.commission.CustomerCommissionService;
import cn.iocoder.yudao.module.customer.service.customer.complaint.CustomerComplaintService;
import cn.iocoder.yudao.module.customer.service.customer.complaint.follow.CustomerFollowService;
import cn.iocoder.yudao.module.customer.service.customerContacts.CustomerContactsService;
import cn.iocoder.yudao.module.customer.service.customerCredit.CustomerCreditService;
import cn.iocoder.yudao.module.customer.service.customerLevel.CustomerLevelService;
import cn.iocoder.yudao.module.customer.service.customerLevelLog.CustomerLevelLogService;
import cn.iocoder.yudao.module.customer.service.customerLevelLog.CustomerLevelLogServiceImpl;
import cn.iocoder.yudao.module.customer.service.customerOperateLog.CustomerOperateLogService;
import cn.iocoder.yudao.module.customer.vo.customerOperateLog.CustomerOperateLogCreateReqVO;
import cn.iocoder.yudao.module.ecw.enums.CustomerOperateTypeEnum;
import cn.iocoder.yudao.module.order.dal.dataobject.targetLog.TargetLogDO;
import cn.iocoder.yudao.module.order.service.targetLog.TargetLogService;
import cn.iocoder.yudao.module.product.dal.dataobject.productbrandempower.ProductBrandEmpowerDO;
import cn.iocoder.yudao.module.product.service.productbrandempower.ProductBrandEmpowerServiceImpl;
import cn.iocoder.yudao.module.sale.dal.dataobject.offer.OfferDO;
import cn.iocoder.yudao.module.sale.service.offer.OfferService;
import cn.iocoder.yudao.module.wealth.dal.dataobject.commissionPayable.CommissionPayableDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.commissionPayment.CommissionPaymentDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receipt.ReceiptDO;
import cn.iocoder.yudao.module.wealth.service.commissionPayable.CommissionPayableService;
import cn.iocoder.yudao.module.wealth.service.commissionPayment.CommissionPaymentService;
import cn.iocoder.yudao.module.wealth.service.receipt.ReceiptServiceImpl;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Log4j2
@Service
@Validated
public class CustomerMergeServiceImpl implements CustomerMergeService {
@Resource
private OrderApi orderApi;
@Resource
OfferService offerService;
//客户跟进
@Resource
CustomerFollowService customerFollowService;
@Resource
private CustomerComplaintService customerComplaintService;
@Resource
private ReceiptServiceImpl receiptService;
@Resource
private ProductBrandEmpowerServiceImpl productBrandEmpowerService;
//客户登记日志
@Resource
private CustomerLevelLogService customerLevelLogService;
@Resource
private CustomerOperateLogService customerOperateLogService;
@Resource
private TargetLogService targetLogService;
@Resource
private CommissionPayableService commissionPayableService;
@Resource
private CommissionPaymentService commissionPaymentService;
@Resource
private CustomerContactsService customerContactsService;
@Resource
private CustomerCommissionService customerCommissionService;
@Resource
private CustomerService customerService;
@Transactional(rollbackFor = Exception.class)
@Override
public boolean doMergeCus(CustomerDO customerDOSaved, CustomerDO customerDODeleted, long loginUserId) {
/*
提交验证:
当保留客户和非主客户的客户经理均不为空且不是同一个用户(允许客户在公海),
弹出提示:保留客户和非主客户,不能在两个不同的客户经理名下,
请先确认两个客户在同一个客户经理名下,不允许提交
当非主客户/保留客户在移交过程中,不允许合并,弹出提示
当允许提交,先弹出上面的注意事项提示,确认后提交
1. 非主客户中的客户联系人所有信息追加到保留客户中,注意:关联账号也需要一并追加
2. 非主客户中的所有关联订单中的客户编号需要更新为保留客户,业绩归属为非主客户,
也需要同时更新为保留客户(此处需要注意有一些订单的收发货人是同一个客户,
还需要注意控货订单的情况,控货权)
3. 非主客户的跟进记录,报价单,客户投诉,品牌授权,
财务相关单据(收款单,佣金请款单,佣金付款单),都需要更新为保留客户
4. 非主客户关联的注册会员信息
4. 提交成功后,非主客户删除,插入记录到保留客户,
备注:客户合并,删除XXX非主客户编号
注意:此处要求是在保留客户中能查询到非主客户的所有信息,
不清楚数据库逻辑结构,此处需要开发查找出所有的关联关系
非主客户关联的订单/收款单/佣金情况单,佣金付款单有在途流程,
需要测试这种情况是否影响合并
*/
//合并订单 在合并订单前会验证非主客户是否有审批中的订单,若存在则不能合并抛出异常
orderApi.mergeOrder(customerDOSaved.getId(), customerDODeleted.getId());
//把客户2的联系方式合并到客户1 1
doMogeContact(customerDOSaved, customerDODeleted, loginUserId);
//合并报价单 2
doMogeOffer(customerDOSaved, customerDODeleted, loginUserId);
//合并跟进记录 3
doMergeCustomerFollow(customerDOSaved, customerDODeleted, loginUserId);
//合并客户投诉 4
doMergeCustomerComplaint(customerDOSaved, customerDODeleted, loginUserId);
//合并产品品牌授权 6
doMergeProductBrandEmpower(customerDOSaved,customerDODeleted,loginUserId);
//合并客户登记日志 7
doMergeCustomerLevelLog(customerDOSaved,customerDODeleted,loginUserId);
//合并信用日志 8
customerService.doMergeCustomerCreditLog(customerDOSaved.getId(),
customerDODeleted.getId());
//合并操作日志 9
// customerService.doMergeCustomerOperateLog(customerDO1.getId(),
// customerDODeleted.getId());
//合并收款单信息 5
doMergeeReceipt(customerDOSaved, customerDODeleted, loginUserId);
// 合并订单佣金应付款
doMergeComissionPayable(customerDOSaved, customerDODeleted);
// 合并佣金付款单
doMergeCommissionPayment(customerDOSaved, customerDODeleted);
// 合并业绩
doMergeTargetLog(customerDOSaved, customerDODeleted);
// 删除客户
customerService.deleteCustomer(customerDODeleted.getId());
// 纪录客户合并日志
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
CustomerOperateLogCreateReqVO customerOperateLogCreateReqVO = new CustomerOperateLogCreateReqVO()
.setOperator(loginUser == null ? null : loginUser.getId())
.setOperatorName(loginUser == null ? null : loginUser.getNickname())
.setCustomerId(customerDOSaved.getId())
.setNumber(customerDOSaved.getNumber())
.setName(customerDOSaved.getName())
.setOldCustomerService(null)
.setNewCustomerService(customerDOSaved.getCustomerService())
.setOldEstimateEnterOpenSeaTime(null)
.setNewEstimateEnterOpenSeaTime(customerDOSaved.getEstimateEnterOpenSeaTime())
.setOrderId(null)
.setOrderNo(null)
.setOperateType(CustomerOperateTypeEnum.CUSTOMER_MERGE.getValue())
.setRemark(String.format("客户合并,删除非主客户【%d-%s-%s】", customerDODeleted.getId(), customerDODeleted.getNumber(), customerDODeleted.getName()));
customerOperateLogService.createOperateLog(customerOperateLogCreateReqVO);
//纪录被删除的客户的日志
CustomerOperateLogCreateReqVO customerOperateLogCreateReqVO2 = new CustomerOperateLogCreateReqVO()
.setOperator(loginUser == null ? null : loginUser.getId())
.setOperatorName(loginUser == null ? null : loginUser.getNickname())
.setCustomerId(customerDODeleted.getId())
.setNumber(customerDODeleted.getNumber())
.setName(customerDODeleted.getName())
.setOldCustomerService(null)
.setNewCustomerService(customerDODeleted.getCustomerService())
.setOldEstimateEnterOpenSeaTime(null)
.setNewEstimateEnterOpenSeaTime(customerDODeleted.getEstimateEnterOpenSeaTime())
.setOrderId(null)
.setOrderNo(null)
.setOperateType(CustomerOperateTypeEnum.CUSTOMER_MERGE.getValue())
.setRemark(String.format("客户合并,将此客户合并到主客户【%d-%s-%s】", customerDOSaved.getId(), customerDOSaved.getNumber(), customerDOSaved.getName()));
customerOperateLogService.createOperateLog(customerOperateLogCreateReqVO2);
return true;
}
private void doMergeCommissionPayment(CustomerDO customerDOSaved, CustomerDO customerDODeleted) {
commissionPaymentService.update(new LambdaUpdateWrapper<CommissionPaymentDO>()
.set(CommissionPaymentDO::getCustomerId, customerDOSaved.getId())
.set(CommissionPaymentDO::getCustomerName, customerDOSaved.getName())
.eq(CommissionPaymentDO::getCustomerId, customerDODeleted.getId()));
}
private void doMergeTargetLog(CustomerDO customerDOSaved, CustomerDO customerDODeleted) {
targetLogService.update(new LambdaUpdateWrapper<TargetLogDO>()
.set(TargetLogDO::getCustomerId, customerDOSaved.getId())
.set(TargetLogDO::getCustomerType, customerDOSaved.getType())
.eq(TargetLogDO::getCustomerId, customerDODeleted.getId()));
}
private void doMergeComissionPayable(CustomerDO customerDOSaved, CustomerDO customerDODeleted) {
commissionPayableService.update(new LambdaUpdateWrapper<CommissionPayableDO>()
.set(CommissionPayableDO::getCustomerId, customerDOSaved.getId())
.set(CommissionPayableDO::getCustomerName, customerDOSaved.getName())
.eq(CommissionPayableDO::getCustomerId, customerDODeleted.getId()));
}
//合并客户信用日志
private void doMergeCustomerLevelLog(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId)
{
customerService.doMergeCustomerLevelLog(customerDOSaved.getId(),
customerDODeleted.getId());
}
//合并产品品牌授权
private void doMergeProductBrandEmpower(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId)
{
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<ProductBrandEmpowerDO>().
eq(ProductBrandEmpowerDO::getCustomerId,
customerDODeleted.getId());
List<ProductBrandEmpowerDO> list =
productBrandEmpowerService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (ProductBrandEmpowerDO d : list
) {
d.setCustomerId(customerDOSaved.getId());
productBrandEmpowerService.updateById(d);
}
}
private void doMergeCustomerComplaint(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerComplaintDO>().
eq(CustomerComplaintDO::getCustomerId,
customerDODeleted.getId());
List<CustomerComplaintDO> list =
customerComplaintService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (CustomerComplaintDO d : list
) {
d.setCustomerId(customerDOSaved.getId());
customerComplaintService.updateById(d);
}
}
//合并收款单
private void doMergeeReceipt(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<ReceiptDO>().
eq(ReceiptDO::getCustomerId, customerDODeleted.getId());
List<ReceiptDO> list = receiptService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (ReceiptDO d : list
) {
d.setCustomerId(customerDOSaved.getId());
receiptService.updateById(d);
}
}
//合并客户跟进
private void doMergeCustomerFollow(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerFollowDO>().
eq(CustomerFollowDO::getCustomerId, customerDODeleted.getId());
List<CustomerFollowDO> list = customerFollowService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (CustomerFollowDO d : list
) {
d.setCustomerId(customerDOSaved.getId());
customerFollowService.updateById(d);
}
}
//合并报价单
private void doMogeOffer(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<OfferDO>().
eq(OfferDO::getRelationId, customerDODeleted.getId());
List<OfferDO> list = offerService.selectList(q2);
if (CollectionUtil.isEmpty(list)) return;
for (OfferDO o : list
) {
o.setRelationId(customerDOSaved.getId());
o.setUpdateTime(new Date());
offerService.updateById(o);
}
}
//合并联系人
private void doMogeContact(CustomerDO customerDOSaved,
CustomerDO customerDODeleted,
long loginUserId) {
LambdaQueryWrapperX q2 =
new LambdaQueryWrapperX<CustomerContactsDO>().
eq(CustomerContactsDO::getCustomerId, customerDODeleted.getId());
List<CustomerContactsDO> cuscontactList2 =
customerContactsService.selectList(q2);
if (CollectionUtil.isNotEmpty(cuscontactList2)) {
for (CustomerContactsDO d : cuscontactList2
) {
d.setCustomerId(customerDOSaved.getId());
//被合并的客户联系人,默认为非默认
d.setIsDefault(0);
d.setUpdateTime(new Date());
d.setUpdater(String.valueOf(loginUserId));
customerContactsService.updateById(d);
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment