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 56727927..b5040b27 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 @@ -57,9 +57,18 @@ 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()); + return AjaxResult.success("消费者已存在分销信息"); + } + if (customer.getCustomerPlace() == customer.getCustomerId()) { + logger.info("消费者id与父级分销人id相同,无效分销信息,customerId=" + lowerCustomer.getCustomerId()); + return AjaxResult.success("无效分销信息"); + } // 更新父级分销人时需要查询是否有祖父分销人,并进行同步更新 - Customer customerPlaceInfo = customerService.selectByCustomerId(customer.getCustomerPlace()); - customer.setParentCustomerPlace(customerPlaceInfo.getCustomerPlace()); + Customer upperCustomer = customerService.selectByCustomerId(customer.getCustomerPlace()); + customer.setParentCustomerPlace(upperCustomer.getCustomerPlace()); } customerService.updateCustomer(customer); return AjaxResult.success("更新消费者信息成功");