消费者分销信息更新加判断

This commit is contained in:
donqi 2022-07-14 16:29:10 +08:00
parent c150b97111
commit a50ccc7f1a
1 changed files with 11 additions and 2 deletions

View File

@ -57,9 +57,18 @@ public class CustomerController extends BaseController {
public AjaxResult updateCustomer(@RequestBody Customer customer){ public AjaxResult updateCustomer(@RequestBody Customer customer){
try { try {
if (customer.getCustomerPlace() != null) { 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 upperCustomer = customerService.selectByCustomerId(customer.getCustomerPlace());
customer.setParentCustomerPlace(customerPlaceInfo.getCustomerPlace()); customer.setParentCustomerPlace(upperCustomer.getCustomerPlace());
} }
customerService.updateCustomer(customer); customerService.updateCustomer(customer);
return AjaxResult.success("更新消费者信息成功"); return AjaxResult.success("更新消费者信息成功");