package com.gic.haoban.manage.service.service.content.impl;

import com.gic.api.base.commons.Page;
import com.gic.haoban.manage.api.dto.StaffClerkRelationDTO;
import com.gic.haoban.manage.api.dto.StaffDTO;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.StaffService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.service.content.MaterialReportService;
import com.gic.haoban.manage.service.service.notify.NoticeMessageService;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author MUSI
 * @Date 2023/3/24 3:59 PM
 * @Description
 * @Version
 **/
@Component
public class MaterialReportServiceImpl implements MaterialReportService {

    private static final Logger log = LoggerFactory.getLogger(MaterialReportServiceImpl.class);

    @Autowired
    private NoticeMessageService noticeMessageService;

    @Autowired
    private StaffClerkRelationService staffClerkRelationService;

    private static final Integer MAX_SIZE = 1000;



    /**
     * 素材周报
     *
     * @param enterpriseId
     */
    @Override
    public void handlerMaterialWeekReport(String enterpriseId) {

        // 获取企业有绑定关系成员 (分页)
        List<StaffClerkRelationDTO> staffClerkRelations = staffClerkRelationService.listAllRelationDtosByEnterpriseId(enterpriseId);
        if (CollectionUtils.isEmpty(staffClerkRelations)) {
            return;
        }
        // 获取成员与导购所有的绑定关系
        Map<String, List<StaffClerkRelationDTO>> staffClerkRelationMap = staffClerkRelations
                .stream()
                .collect(Collectors.groupingBy(StaffClerkRelationDTO::getStaffId));
        // 获取成员 主门店信息 没有就是区经
        for (Map.Entry<String, List<StaffClerkRelationDTO>> entry : staffClerkRelationMap.entrySet()) {
            String staffId = entry.getKey();
            List<StaffClerkRelationDTO> clerkRelations = entry.getValue();
        }
        // 获取成员周报/月报数据

        // 保存好办小程序内消息

        // 群发企微应用消息

    }
}
