diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerChangeBizService.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerChangeBizService.java index 1fb1fe9..e15371c 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerChangeBizService.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/cust/CustomerChangeBizService.java @@ -279,7 +279,7 @@ public class CustomerChangeBizService extends AbstractCustomerService { return true; } Long adviserId = changeAdviserReq.getAdviserId(); - if (changeAdviserReq.getAdviserId().equals(customer.getAdviserId())) { + if (adviserId.equals(customer.getAdviserId())) { return true; } List dataRange = userService.getUserRoleDataRange(adviserId, RoleCode.FWGW); @@ -297,12 +297,14 @@ public class CustomerChangeBizService extends AbstractCustomerService { AffiliationRecord entity = createEntity(customer, adviserId, shopId); entity.setReason(DefeatReasonEnum.SYS.getName()); affiliationRecordService.save(entity); - - StammkundePool pool = stammkundePoolService.queryAktivAble(customer.getId(), customer.getGroupId(), customer.getShopId()); + StammkundePool pool = stammkundePoolService.getOne(Wrappers.lambdaQuery() + .eq(StammkundePool::getCustomerId, customer.getId()) + .eq(StammkundePool::getGroupId, customer.getGroupId()) + .eq(StammkundePool::getAdviserId, customer.getAdviserId()) + .eq(StammkundePool::getAktiv, Boolean.TRUE) + ); if (Objects.nonNull(pool)) { - stammkundePoolService.aktiv(pool.getId()); - } else { - create(customer, adviserId, false); + stammkundePoolService.reject(customer.getId(), customer.getGroupId()); } } if (Objects.isNull(customer.getAdviserId()) && Objects.isNull(customer.getShopId())) { diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java index ac8538c..1cef64e 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/FMFollowStrategy.java @@ -145,13 +145,16 @@ public class FMFollowStrategy extends AbstractFollowStrategy { public boolean origin2task(OriginalData originalData) throws Exception { Customer customer = customerService.queryById(originalData.getCustomerId()); BV.notNull(customer, () -> "档案不存在"); + boolean bool = Objects.isNull(customer.getAdviserId()) || Objects.isNull(customer.getShopId()); + BV.isFalse(bool, () -> "档案信息不完整"); + CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customer.getId(), customer.getGroupId(), getFollowType()); if (DataTypeEnum.FM.equals(originalData.getType())) { - CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customer.getId(), customer.getGroupId(), getFollowType()); completeClue(cluePool, originalData); return true; } - boolean bool = Objects.isNull(customer.getAdviserId()) || Objects.isNull(customer.getShopId()); - BV.isFalse(bool, () -> "档案信息不完整"); + if (DataTypeEnum.OD.equals(originalData.getType()) && Objects.nonNull(cluePool) && ClueStatusEnum.WAITING.equals(cluePool.getClueStatus())) { + customerCluePoolService.removeById(cluePool.getId()); + } CustomerCluePool clue = createClueInfo(originalData, getFollowType(), customer); customerCluePoolService.save(clue); createFirstNotice(clue, originalData.getGenerateTime()); diff --git a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java index 0affec6..9e6238c 100644 --- a/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java +++ b/fw-valhalla-service/src/main/java/cn/fw/valhalla/service/bus/follow/strategy/impl/RMFollowStrategy.java @@ -17,6 +17,8 @@ import cn.fw.valhalla.domain.vo.setting.SettingVO; import cn.fw.valhalla.rpc.erp.dto.UserInfoDTO; import cn.fw.valhalla.rpc.oop.dto.ShopDTO; import cn.fw.valhalla.sdk.enums.DataTypeEnum; +import cn.fw.valhalla.sdk.param.ChangeAdviserReq; +import cn.fw.valhalla.service.bus.cust.CustomerChangeBizService; import cn.fw.valhalla.service.bus.follow.strategy.AbstractFollowStrategy; import cn.fw.valhalla.service.data.OriginalDataService; import com.baomidou.mybatisplus.core.toolkit.Wrappers; @@ -44,10 +46,13 @@ import static cn.fw.common.businessvalidator.Validator.BV; @Component public class RMFollowStrategy extends AbstractFollowStrategy { private final OriginalDataService originalDataService; + private final CustomerChangeBizService changeBizService; @Autowired - public RMFollowStrategy(final OriginalDataService originalDataService) { + public RMFollowStrategy(final OriginalDataService originalDataService, + final CustomerChangeBizService changeBizService) { this.originalDataService = originalDataService; + this.changeBizService = changeBizService; } @Override @@ -155,7 +160,18 @@ public class RMFollowStrategy extends AbstractFollowStrategy { CustomerCluePool cluePool = customerCluePoolService.queryByRefererId(customer.getId(), customer.getGroupId(), getFollowType()); completeClue(cluePool, originalData); boolean bool = Objects.isNull(customer.getAdviserId()) || Objects.isNull(customer.getShopId()); + if (Objects.nonNull(originalData.getShopId()) && Objects.nonNull(originalData.getUserId()) && bool) { + ChangeAdviserReq req = new ChangeAdviserReq(); + req.setAdviserId(originalData.getUserId()); + req.setCusId(customer.getId()); + if (changeBizService.changeAdviser(req)) { + customer.setAdviserId(originalData.getUserId()); + customer.setShopId(originalData.getShopId()); + bool = false; + } + } BV.isFalse(bool, () -> "档案信息不完整"); + CustomerCluePool clue = createClueInfo(originalData, getFollowType(), customer); customerCluePoolService.save(clue); createFirstNotice(clue, originalData.getGenerateTime());