From 171bcec9e6418ccb7ed53396a79bc245b997f0d3 Mon Sep 17 00:00:00 2001 From: donqi Date: Mon, 7 Nov 2022 00:54:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=94=80=E8=80=85=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../customer/CustomerController.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java index 11a64c61..37c6b159 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/customer/CustomerController.java @@ -4,6 +4,7 @@ import com.ghy.common.adapay.model.AnalyseItemEnum; import com.ghy.common.core.controller.BaseController; import com.ghy.common.core.domain.AjaxResult; import com.ghy.common.core.page.TableDataInfo; +import com.ghy.common.enums.PlaceStatus; import com.ghy.common.utils.ExceptionUtil; import com.ghy.customer.domain.Customer; import com.ghy.customer.service.CustomerService; @@ -164,18 +165,30 @@ public class CustomerController extends BaseController { public AjaxResult updateCustomer(@RequestBody Customer customer){ try { if (customer.getCustomerPlace() != null) { - Customer lowerCustomer = customerService.selectByCustomerId(customer.getCustomerId()); - if (lowerCustomer.getCustomerPlace() != null) { - logger.info("消费者已存在分销人信息,customerId=" + lowerCustomer.getCustomerId()); + Customer curCustomer = customerService.selectByCustomerId(customer.getCustomerId()); + Customer placeCustomer = customerService.selectByCustomerId(customer.getCustomerPlace()); + if (curCustomer.getCustomerPlace() != null) { + logger.info("消费者已存在分销人信息,customerId=" + curCustomer.getCustomerId()); return AjaxResult.success("消费者已存在分销信息"); } if (customer.getCustomerPlace() == customer.getCustomerId()) { - logger.info("消费者id与父级分销人id相同,无效分销信息,customerId=" + lowerCustomer.getCustomerId()); + logger.info("消费者id与父级分销人id相同,无效分销信息,customerId=" + curCustomer.getCustomerId()); return AjaxResult.success("无效分销信息"); } + logger.info("开始查找有效分销者"); + if (!PlaceStatus.CAN_PLACE.getCode().equals(placeCustomer.getPlaceStatus())) { + // 当前placeCustomer未通过分销资格审核,查找再上一级分销者 + if (placeCustomer.getCustomerPlace() == null) { + logger.info("无有效上级分销者"); + return AjaxResult.success(); + } else { + placeCustomer = customerService.selectByCustomerId(placeCustomer.getCustomerPlace()); + logger.info("存在有效上级分销者:" + placeCustomer.getCustomerId()); + } + } // 更新父级分销人时需要查询是否有祖父分销人,并进行同步更新 - Customer upperCustomer = customerService.selectByCustomerId(customer.getCustomerPlace()); - customer.setParentCustomerPlace(upperCustomer.getCustomerPlace()); + customer.setCustomerPlace(placeCustomer.getCustomerId()); + customer.setParentCustomerPlace(placeCustomer.getCustomerPlace()); } customerService.updateCustomer(customer); return AjaxResult.success("更新消费者信息成功");