package com.erp.customer.service;

import com.erp.customer.dto.CustomerRelationshipRequest;
import com.erp.customer.entity.CustomerRelationship;

import java.util.List;

/**
 * 客户关系Service接口（8级客户关系）
 */
public interface CustomerRelationshipService {
    
    /**
     * 获取客户的所有关系
     */
    List<CustomerRelationship> getRelationshipsByCustomerId(Long customerId);
    
    /**
     * 根据ID获取关系
     */
    CustomerRelationship getRelationshipById(Long id);
    
    /**
     * 创建客户关系
     */
    CustomerRelationship createRelationship(CustomerRelationshipRequest request);
    
    /**
     * 更新客户关系
     */
    CustomerRelationship updateRelationship(Long id, CustomerRelationshipRequest request);
    
    /**
     * 删除客户关系
     */
    void deleteRelationship(Long id);
    
    /**
     * 解除客户关系
     */
    CustomerRelationship terminateRelationship(Long id);
    
    /**
     * 获取客户的所有分店
     */
    List<CustomerRelationship> getBranchesByCustomerId(Long customerId);
    
    /**
     * 获取总店的所有分店（所有层级）
     */
    List<CustomerRelationship> getAllBranchesByHeadquartersId(Long headquartersId);
    
    /**
     * 获取客户的上级
     */
    CustomerRelationship getParentByCustomerId(Long customerId);
    
    /**
     * 获取客户直接上级
     */
    CustomerRelationship getDirectParentByCustomerId(Long customerId);
    
    /**
     * 查询所有总店
     */
    List<CustomerRelationship> getAllHeadquarters(Long tenantId);
    
    /**
     * 根据集团名称查询
     */
    List<CustomerRelationship> getByGroupName(Long tenantId, String groupName);
    
    /**
     * 统计分店数量
     */
    Long countBranchesByCustomerId(Long customerId);
    
    /**
     * 获取客户的所有关联（通过层级路径）
     */
    List<CustomerRelationship> getAllRelatedRelationships(Long customerId);
    
    /**
     * 转移客户到新的父客户
     */
    CustomerRelationship transferCustomer(Long customerId, Long newParentId, Integer newLevel);
}
