package com.rj.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.rj.entity.LbDepartmentUser;

import jakarta.servlet.http.HttpServletResponse;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

public interface ILbDepartmentUserService extends IService<LbDepartmentUser> {

    Map<String, Object> add(LbDepartmentUser entity);

    Map<String, Object> update(LbDepartmentUser entity);

    Map<String, Object> deleteById(String id);

    Map<String, Object> pageQuery(Integer current,
                                  Integer size,
                                  String tenantId,
                                  String userId,
                                  String parentId,
                                  String name,
                                  String phone,
                                  String industry,
                                  Integer isActive);

    Map<String, Object> bindParentUser(String parentUserId,
                                       String parentUserName,
                                       String childUserId,
                                       String childUserName,
                                       String tenantId);

    Map<String, Object> syncFromDailyUserTrade(LocalDate startDate, LocalDate endDate);

    /**
     * 从 lb_user 同步到 lb_department_user，并按 pid 构建 org_chain 上级链条。
     */
    Map<String, Object> syncFromLbUser(String tenantId);

    /**
     * 按租户查询部门用户并构建父子树（parent_id 对应 lb_user.pid）。
     */
    Map<String, Object> getDepartmentUserTree(String tenantId, Integer isActive, LocalDate joinDate, LocalDate lastTradeDate);

    /**
     * 按租户与用户 ID 列表导出部门用户及订单汇总 Excel。
     */
    void exportUsersExcel(String tenantId, List<String> userIds, HttpServletResponse response);
}
