This commit is contained in:
clunt 2022-11-07 01:01:47 +08:00
commit 5371b43766
1 changed files with 19 additions and 6 deletions

View File

@ -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("更新消费者信息成功");