package com.hzs.member.statis.provider;

import cn.hutool.core.collection.CollectionUtil;
import com.hzs.common.core.domain.R;
import com.hzs.member.statis.ICuBonusVertexStatisServiceApi;
import com.hzs.member.statis.service.ICuBonusLenjoyStatisService;
import com.hzs.member.statis.service.ICuBonusVertexStatisService;
import com.hzs.member.statis.vo.CuBonusLenjoyStatisVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;


/**
 * @description: 顶点奖金拨比统计Dubbo 服务
 * @author: zhang jing
 * @date: 2023/6/1 17:25
 * @param:
 * @return:
 **/
@Slf4j
@DubboService
public class ICuBonusVertexStatisServiceProvider implements ICuBonusVertexStatisServiceApi {

    @Autowired
    private ICuBonusVertexStatisService iCuBonusVertexStatisService;
    @Autowired
    private ICuBonusLenjoyStatisService iCuBonusLenjoyStatisService;





    /**
     * @description: 7天重算顶点奖金拨比统计
     * @author: zhang jing
     * @date: 2024/8/15 9:58
     * @param: [startDate, endDate]
     * @return: com.hzs.common.core.domain.R
     **/
    @Override
    public R anewStatisHistoryBonus(String startDate,String endDate) {
        return R.ok(iCuBonusVertexStatisService.anewStatisHistoryBonus( startDate, endDate));
    }


    /**
     * @description: 删除奖金拨比统计数据
     * @author: zhang jing
     * @date: 2023/12/11 10:56
     * @param: [startDate, endDate]
     * @return: com.hzs.common.core.domain.R
     **/
    @Override
    public R delStatis(String startDate,String endDate) {
        List<CuBonusLenjoyStatisVO> vertexList=iCuBonusLenjoyStatisService.vertexList(null);
        List<Integer> pkVertexList= new ArrayList<>();
        pkVertexList.addAll(vertexList.stream().map(CuBonusLenjoyStatisVO::getPkVertex).collect(Collectors.toList()));
        if(CollectionUtil.isNotEmpty(pkVertexList)){
            iCuBonusVertexStatisService.delStatis(startDate, endDate,pkVertexList);
        }
        return R.ok();
    }





}
