package com.hzs.member.achieve.controller.api;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import com.hzs.common.core.constant.CountryConstants;
import com.hzs.common.core.constant.TableNameConstants;
import com.hzs.common.core.constant.msg.ConfigMsgConstants;
import com.hzs.common.core.constant.msg.FinanceMsgConstants;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.EAchievementType;
import com.hzs.common.core.enums.EMonthScoreType;
import com.hzs.common.core.enums.EOrderType;
import com.hzs.common.core.enums.EPlaceDept;
import com.hzs.common.core.utils.ComputeUtil;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.core.utils.poi.ExcelUtil;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.core.web.page.TableDataInfo;
import com.hzs.common.domain.member.achieve.ext.CuMemberAchieveExt;
import com.hzs.common.domain.member.ext.CuMemberMonthAchieveExt;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.common.util.TransactionUtils;
import com.hzs.member.achieve.controller.vo.*;
import com.hzs.member.achieve.param.MemberAchieveDisParam;
import com.hzs.member.achieve.param.MonthAchieveParam;
import com.hzs.member.achieve.service.ICuMemberAchieveService;
import com.hzs.member.achieve.service.ICuMemberMonthAchieveService;
import com.hzs.member.achieve.service.ICuMemberSettlePeriodService;
import com.hzs.system.base.ICurrencyServiceApi;
import com.hzs.system.base.dto.CurrencyDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

/**
 * 会员端查询市场动态的接口
 */
@Slf4j
@RestController
@RequestMapping("/api/achieve")
public class ApiCuMemberAchieveDisController extends BaseController {

    @DubboReference
    ICurrencyServiceApi iCurrencyServiceApi;

    @Autowired
    private ICuMemberSettlePeriodService iCuMemberSettlePeriodService;
    @Autowired
    private ICuMemberAchieveService iCuMemberAchieveService;
    @Autowired
    private ICuMemberMonthAchieveService iCuMemberMonthAchieveService;

    /**
     * 用于查询会员市场动态
     *
     * @param memberAchieveDisParam 查询参数
     */
    @PostMapping("/query-place-tree-detail")
    public AjaxResult queryPlaceParentTreeDetail(@RequestBody MemberAchieveDisParam memberAchieveDisParam) {
        // 查询架构树
        if (StringUtils.isEmpty(memberAchieveDisParam.getMemberCode())) {
            return AjaxResult.error(TransactionUtils.getContent(ConfigMsgConstants.MEMBER_CODE_NOT_NULL));
        }
        memberAchieveDisParam.setPkCountry(SecurityUtils.getPkCountry());
        return AjaxResult.success(iCuMemberAchieveService.queryCuMemberDis(memberAchieveDisParam));
    }

    /**
     * 用于查询会员最近的业绩
     *
     * @param memberAchieveDisParam 查询参数
     */
    @PostMapping("/query-last-achieve")
    public AjaxResult queryLastAchieve(@RequestBody MemberAchieveDisParam memberAchieveDisParam) {
        // 业绩分布 近7日业绩 左区、右区新增人数 血缘业绩  左区、右区新增业绩
        memberAchieveDisParam.setPkMember(SecurityUtils.getUserId());
        return AjaxResult.success(iCuMemberAchieveService.queryCuMemberUnderBloodAchieveByPkMember(memberAchieveDisParam));
    }

    /**
     * 用于查询会员真实业绩
     *
     * @param memberAchieveDisParam 查询参数
     */
    @PostMapping("/query-real-achieve")
    public AjaxResult queryRealAchieve(@RequestBody MemberAchieveDisParam memberAchieveDisParam) {
        // 业绩分布 近7日业绩 左区、右区新增人数 血缘业绩  左区、右区新增业绩
        memberAchieveDisParam.setPkMember(SecurityUtils.getUserId());
        return AjaxResult.success(iCuMemberAchieveService.queryCuMemberUnderBloodAchieveByPkMember(memberAchieveDisParam));
    }

    /**
     * 查询会员真实业绩
     */
    @GetMapping("/query-real-performance")
    public AjaxResult queryRealPerformance(Integer month) {
        RealPerformanceVo realPerformanceVo = iCuMemberAchieveService.queryRealPerformance(SecurityUtils.getUserId(), SecurityUtils.getPkCountry(), month);
        return AjaxResult.success(realPerformanceVo);
    }


    /**
     * 会员真实业绩分布
     *
     * @return
     */
    @GetMapping("/query-real-performance-pic")
    public AjaxResult queryRealPerformancePic() {

        int month = DateUtil.month(DateUtils.currentDate()) + 1;
        AzAchievementPie achievementPie = iCuMemberAchieveService.queryRealPerformancePic(SecurityUtils.getUserId(), SecurityUtils.getPkCountry(), month);

        return AjaxResult.success(achievementPie);
    }


    /**
     * 月度新增业绩对比
     *
     * @param month 月份
     * @return AjaxResult
     */
    @GetMapping("/new-add-achieve-contrast")
    public AjaxResult queryNewAddAchieveContrast(Integer month) {
        return AjaxResult.success(iCuMemberAchieveService.selectNewAddAchieveContrast(SecurityUtils.getUserId(), SecurityUtils.getPkCountry(), month));
    }


    /**
     * 月度业绩-新增业绩统计
     **/
    @GetMapping("/place-new-add-achieve-stat")
    public AjaxResult placeNewAddAchieveStat(PlaceNewAddAchieveVO pna) {
        pna.setPkMember(SecurityUtils.getUserId());
        pna.setPkCountry(SecurityUtils.getPkCountry());
        if (null == pna.getAchievementType()) {
            pna.setAchievementType(EAchievementType.WHOLE.getValue());
        }
        pna = iCuMemberAchieveService.placeNewAddAchieveStat(pna);

        return AjaxResult.success(pna);
    }

    /**
     * 月度业绩-详情
     **/
    @GetMapping("/place-new-add-achieve-details")
    public TableDataInfo placeNewAddAchieveDetails(PlaceNewAddAchieveVO pna) {
        //当前日期
        Date currentDate;
        LocalDate localDate;
        LocalDate startDate;
        if (StringUtils.isNotEmpty(pna.getYear())) {
            currentDate = iCuMemberAchieveService.getDateFromYearAndMonth(pna.getYear(), pna.getMonthType().toString());
            LocalDate today = currentDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
            //当月第一天和最后一天
            localDate = null == pna.getMonthType() ? LocalDate.now() : LocalDate.of(today.getYear(), pna.getMonthType(), 1);
            startDate = localDate.with(TemporalAdjusters.firstDayOfMonth());
        } else {
            //当月第一天和最后一天
            localDate = null == pna.getMonthType() ? LocalDate.now() : LocalDate.of(LocalDate.now().getYear(), pna.getMonthType(), 1);
            startDate = localDate.with(TemporalAdjusters.firstDayOfMonth());
        }
        Date systemDate = DateUtils.currentDate();
        List<Integer> orderTypeList = new ArrayList<>();
        Integer pkCountry = SecurityUtils.getPkCountry();
        R<CurrencyDTO> currency = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry());
        pna.setPkMember(SecurityUtils.getUserId());
        pna.setPkCountry(SecurityUtils.getPkCountry());
        pna.setPkCountry(pkCountry);

        // 获取下个月第一天
        LocalDate endDate = localDate.with(TemporalAdjusters.firstDayOfNextMonth());
        Date enddate = DateUtils.toDate(endDate);
        String startDateStr = "";
        String endDateStr = "";
        if (pna.getMonthScoreType() == null) {
            pna.setMonthScoreType(EMonthScoreType.PEOPLE_NUMBER.getValue());
        }
        // 获取下个月第一天
        if (DateUtils.compareDateBefore(systemDate, enddate)) {
            if (pna.getMonthScoreType() == EMonthScoreType.SCORE.getValue() ||
                    pna.getMonthScoreType() == EMonthScoreType.BLOOD_SCORE.getValue() ||
                    pna.getMonthScoreType() == EMonthScoreType.DIRECT_SCORE.getValue()) {
                endDate = DateUtils.toLocalDate(DateUtils.beforeDate(1, ChronoUnit.DAYS, systemDate));
                if (DateUtils.compareDateBefore(DateUtils.toDate(endDate), DateUtils.toDate(startDate))) {
                    startDateStr = DateUtils.currentMonthFirstDateStr(DateUtils.toDate(endDate));
                    endDateStr = DateUtils.currentMonthLastDateStr(DateUtils.toDate(endDate));
                }
            } else {
                endDate = DateUtils.toLocalDate(systemDate);
            }
        } else {
            endDate = DateUtils.toLocalDate(DateUtils.beforeDate(1, ChronoUnit.DAYS, DateUtils.toDate(endDate)));
        }
        if (StringUtils.isEmpty(startDateStr) &&
                StringUtils.isEmpty(endDateStr)) {
            startDateStr = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
            endDateStr = endDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        }
        if (StringUtils.isEmpty(pna.getStartDate()) &&
                StringUtils.isEmpty(pna.getEndDate())) {
            pna.setStartDate(startDateStr);
            pna.setEndDate(endDateStr);
        }
        if (null == pna.getAchievementType()) {
            pna.setAchievementType(EAchievementType.WHOLE.getValue());
        }
        if (null == pna.getPlaceDept()) {
            pna.setPlaceDept(EPlaceDept.LEFT_DEPT.getValue());
        }

        if (pna.getMonthScoreType() == EMonthScoreType.PEOPLE_NUMBER.getValue()) {
            orderTypeList.add(EOrderType.REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.FICTITIOUS_ORDER.getValue());
        } else if (pna.getAchievementType() == EAchievementType.FIRST_PURCHASE.getValue()) {
            //首购
            orderTypeList.add(EOrderType.REGISTER_ORDER.getValue());
            orderTypeList.add(EOrderType.UPGRADE_ORDER.getValue());
            orderTypeList.add(EOrderType.FICTITIOUS_ORDER.getValue());
        } else if (pna.getAchievementType() == EAchievementType.REPURCHASE.getValue()) {
            //复购
            orderTypeList.add(EOrderType.REPURCHASE_ORDER.getValue());
            orderTypeList.add(EOrderType.MALL_ORDER.getValue());
        }
        pna.setOrderTypeList(orderTypeList);
        startPage();
        List<PlaceNewAddAchieveVO> pnaList = new ArrayList<>();
        //查询左右区人列表最新数据
        if (pna.getMonthScoreType() == null || pna.getMonthScoreType() == EMonthScoreType.PEOPLE_NUMBER.getValue()) {
            if (DateUtils.compareDateBefore(systemDate, enddate)) {
                pnaList = iCuMemberAchieveService.placeNewAddAchieveDetails(pna);
            } else {
                //查询左右区人列表历史数据
                int frontLastendperiod = iCuMemberSettlePeriodService.getCuMemberSettlePeriodByDate(
                        DateUtils.parseDateToStr(endDateStr)).getPkId();
                String frontTreeTableNameEnd = TableNameConstants.CU_MEMBER_SETTLE + frontLastendperiod;
                pna.setAchieveTableName(frontTreeTableNameEnd);
                pnaList = iCuMemberAchieveService.placeNewAddAchieveHistoryDetails(pna);
            }
        } else if (pna.getMonthScoreType() == EMonthScoreType.SCORE.getValue()) {
            //查询左右区业绩详情
            //查询最新期数
            int endperiod = iCuMemberSettlePeriodService.getCuMemberSettlePeriodByDate(
                    DateUtils.parseDateToStr(endDateStr)).getPkId();
            pna.setPeriod(endperiod);
            String achieveTableName = TableNameConstants.CU_MEMBER_TREE + DateUtils.getMonth(startDateStr);
            pna.setAchieveTableName(achieveTableName);
            pnaList = iCuMemberAchieveService.leftRightAchieveDetails(pna);
        } else if (pna.getMonthScoreType() == EMonthScoreType.BLOOD_SCORE.getValue()) {
            //查询左右区血缘业绩详情
            String achieveTableName = TableNameConstants.CU_MEMBER_MONTH + DateUtils.getMonth(startDateStr);
            pna.setAchieveTableName(achieveTableName);
            pnaList = iCuMemberAchieveService.leftRightDirectAchieveDetails(pna);
        } else if (pna.getMonthScoreType() == EMonthScoreType.DIRECT_SCORE.getValue()) {
            //查询血缘业绩详情
            String achieveTableName = TableNameConstants.CU_MEMBER_MONTH + DateUtils.getMonth(startDateStr);
            pna.setAchieveTableName(achieveTableName);
            pnaList = iCuMemberAchieveService.directAchieveDetails(pna);
        }

        if (CollectionUtil.isNotEmpty(pnaList)) {
            pnaList.forEach(itm -> {
                itm.setMemberName(itm.getMemberName());
                itm.setMemberCode(itm.getMemberCode());
                itm.setOrderAchieve(itm.getOrderAchieve().multiply(currency.getData().getInExchangeRate()));
            });
        }
        return getDataTable(pnaList);
    }

    /**
     * 导出
     **/
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlaceNewAddAchieveVO pna) {
        pna.setPkMember(SecurityUtils.getUserId());
        pna.setPkCountry(SecurityUtils.getPkCountry());
        if (null == pna.getAchievementType()) {
            pna.setAchievementType(EAchievementType.WHOLE.getValue());
        }
        pna = iCuMemberAchieveService.placeNewAddAchieveStat(pna);
        List<PlaceNewAddAchieveVO> list = new ArrayList<>();
        list.add(pna);
        ExcelUtil<PlaceNewAddAchieveVO> util = new ExcelUtil<>(PlaceNewAddAchieveVO.class);
        util.exportExcel(response, list, "血缘业绩");
    }

    /**
     * 业绩分布-直推业绩统计（右图）
     **/
    @PostMapping("/parent-achieve-right")
    public AjaxResult parentAchieveRight(@RequestBody ParentAchieveVO pa) {
        if (StringUtils.isEmpty(pa.getMonth())) {
            return AjaxResult.error(TransactionUtils.getContent(FinanceMsgConstants.SELECT_DATE_NOT_NULL));
        }
        Date d = DateUtils.parseStringToDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentDate()));
        pa.setEndDate(lastDayByMonth(pa.getMonth()));
        Date enddate = DateUtils.parseStringToDate(pa.getEndDate());
        if (DateUtils.compareDateBefore(d, enddate) || DateUtils.compareDateEqual(d, enddate)) {
            pa.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, d)));
        }
        pa.setPkMember(SecurityUtils.getUserId());
        pa.setPkCountry(SecurityUtils.getPkCountry());
        pa = iCuMemberAchieveService.parentAchieveRight(pa);
        return AjaxResult.success(pa);
    }

    /**
     * 业绩分布-直推业绩统计（左图）
     **/
    @PostMapping("/parent-achieve-left")
    public AjaxResult parentAchieveLeft(@RequestBody ParentAchieveVO pa) {
        if (StringUtils.isEmpty(pa.getMonth())) {
            return AjaxResult.error(TransactionUtils.getContent(FinanceMsgConstants.SELECT_DATE_NOT_NULL));
        }
        Date d = DateUtils.parseStringToDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.currentDate()));
        pa.setEndDate(lastDayByMonth(pa.getMonth()));
        Date enddate = DateUtils.parseStringToDate(pa.getEndDate());
        if (DateUtils.compareDateBefore(d, enddate) || DateUtils.compareDateEqual(d, enddate)) {
            pa.setEndDate(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.beforeDate(1, ChronoUnit.DAYS, d)));
        }
        pa.setPkMember(SecurityUtils.getUserId());
        pa.setPkCountry(SecurityUtils.getPkCountry());
        List<ParentAchieveVO> paList = iCuMemberAchieveService.parentAchieveLeft(pa);
        return AjaxResult.success(paList);
    }

    /**
     * 根据月查询该月的最后一天
     **/
    public String lastDayByMonth(String endDate) {
        // 将月份字符串转换为 LocalDate 对象
        LocalDate date = LocalDate.parse(endDate + "-01");
        // 获取该月的最后一天
        int lastDay = date.lengthOfMonth();
        // 构建具体的日期和时间
        LocalDateTime lastDayDateTime = LocalDateTime.of(date.withDayOfMonth(lastDay), LocalTime.MAX);
        // 定义日期时间格式化模式
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        // 格式化日期时间为字符串
        endDate = lastDayDateTime.format(formatter);
        return endDate;
    }

    /**
     * 推荐分布
     **/
    @PostMapping("/recommend")
    public TableDataInfo recommendExperts(@RequestBody ParentAchieveVO parentAchieveVO) {
        if (parentAchieveVO.getWallType() == null) {
            return new TableDataInfo();
        }
        parentAchieveVO.setPkCountry(SecurityUtils.getPkCountry());
        List<CuMemberMonthAchieveExt> cuMemberMonthAchieveExtList = iCuMemberMonthAchieveService.queryCuMemberMonthAchieveRecommend(parentAchieveVO);
        cuMemberMonthAchieveExtList.forEach(cuMemberMonthAchieveExt -> {
            String memberName = cuMemberMonthAchieveExt.getMemberName();
            if (memberName.length() > 2) {
                cuMemberMonthAchieveExt.setMemberName(memberName.replaceFirst(memberName.substring(1, memberName.length() - 1), "*"));
            } else {
                cuMemberMonthAchieveExt.setMemberName(memberName.replaceFirst(memberName.substring(1), "*"));
            }
        });
        return getDataTable(cuMemberMonthAchieveExtList);
    }


    /**
     * 月度业绩
     **/
    @PostMapping("/month-achieve")
    public TableDataInfo memberMonthAchieve(@RequestBody MonthAchieveParam monthAchieveParam) {
        List<MemberMonthAchieveVO> memberMonthAchieveList = new ArrayList<>();
        List<CuMemberAchieveExt> cuMemberAchieveExtList = iCuMemberAchieveService.queryMemberMonthAchieve(SecurityUtils.getUserId(), monthAchieveParam.getMonth());
        for (CuMemberAchieveExt cuMemberAchieveExt : cuMemberAchieveExtList) {
            MemberMonthAchieveVO memberMonthAchieveVO = BeanUtil.copyProperties(cuMemberAchieveExt, MemberMonthAchieveVO.class);
            setAchieve(cuMemberAchieveExt, memberMonthAchieveVO);
            if (StringUtils.isNotEmpty(memberMonthAchieveVO.getMonth())) {
                String month = memberMonthAchieveVO.getMonth();
                memberMonthAchieveVO.setMonth(month.substring(0, 4) + "-" + month.substring(4));
            }
            memberMonthAchieveList.add(memberMonthAchieveVO);
        }
        return getDataTable(memberMonthAchieveList);
    }

    private void setAchieve(CuMemberAchieveExt cuMemberAchieveExt, MemberMonthAchieveVO memberMonthAchieveVO) {
        if (Objects.equals(CountryConstants.CHINA_COUNTRY, cuMemberAchieveExt.getPkSettleCountry())) {
            memberMonthAchieveVO.setASumPv(ComputeUtil.computeMultiply(memberMonthAchieveVO.getASumPv(), cuMemberAchieveExt.getOutExchangeRate()));
            memberMonthAchieveVO.setBSumPv(ComputeUtil.computeMultiply(memberMonthAchieveVO.getBSumPv(), cuMemberAchieveExt.getOutExchangeRate()));
            memberMonthAchieveVO.setRepASumPv(ComputeUtil.computeMultiply(memberMonthAchieveVO.getRepASumPv(), cuMemberAchieveExt.getOutExchangeRate()));
            memberMonthAchieveVO.setRepBSumPv(ComputeUtil.computeMultiply(memberMonthAchieveVO.getRepBSumPv(), cuMemberAchieveExt.getOutExchangeRate()));
            memberMonthAchieveVO.setFirstAchieve(ComputeUtil.computeMultiply(memberMonthAchieveVO.getFirstAchieve(), cuMemberAchieveExt.getOutExchangeRate()));
            memberMonthAchieveVO.setRepurchaseAchieve(ComputeUtil.computeMultiply(memberMonthAchieveVO.getRepurchaseAchieve(), cuMemberAchieveExt.getOutExchangeRate()));
        }
    }

    /**
     * 月度业绩详细
     **/
    @PostMapping("/month-achieve-detail")
    public TableDataInfo memberMonthAchieveDetail(@RequestBody MonthAchieveParam monthAchieveParam) {
        List<MemberMonthAchieveVO> memberMonthAchieveList = new ArrayList<>();
        if (StringUtils.isNotEmpty(monthAchieveParam.getMonth()) && monthAchieveParam.getPlaceDept() != null) {
            startPage();
            Date startDate = DateUtils.parseStringToDate(monthAchieveParam.getMonth() + "-01");
            Date endDate = DateUtils.currentMonthLastDate(startDate);
            monthAchieveParam.setStartDate(startDate);
            monthAchieveParam.setEndDate(endDate);
            monthAchieveParam.setPkMember(SecurityUtils.getUserId());
            List<CuMemberAchieveExt> cuMemberAchieveExtList;
            monthAchieveParam.setMonth(monthAchieveParam.getMonth().replace("-", ""));
            if (monthAchieveParam.getPlaceDept() == 0) {
                cuMemberAchieveExtList = iCuMemberAchieveService.queryParentMemberMonthAchieve(monthAchieveParam);
            } else {
                cuMemberAchieveExtList = iCuMemberAchieveService.queryPlaceParentMemberMonthAchieve(monthAchieveParam);
            }
            if (CollectionUtil.isNotEmpty(cuMemberAchieveExtList)) {
                for (CuMemberAchieveExt cuMemberAchieveExt : cuMemberAchieveExtList) {
                    MemberMonthAchieveVO memberMonthAchieveVO = BeanUtil.copyProperties(cuMemberAchieveExt, MemberMonthAchieveVO.class);

                    memberMonthAchieveVO.setMemberCode(cuMemberAchieveExt.getMemberCode());
                    memberMonthAchieveVO.setMemberName(cuMemberAchieveExt.getMemberName());

                    memberMonthAchieveVO.setFirstAchieve(BigDecimal.ZERO);
                    memberMonthAchieveVO.setRepurchaseAchieve(BigDecimal.ZERO);
                    if (EOrderType.REGISTER_ORDER.getValue() == cuMemberAchieveExt.getOrderType()
                            || EOrderType.UPGRADE_ORDER.getValue() == cuMemberAchieveExt.getOrderType()) {
                        if (Objects.equals(CountryConstants.CHINA_COUNTRY, cuMemberAchieveExt.getPkSettleCountry())) {
                            memberMonthAchieveVO.setFirstAchieve(ComputeUtil.computeMultiply(cuMemberAchieveExt.getOrderAchieve(), cuMemberAchieveExt.getOutExchangeRate()));
                        } else {
                            memberMonthAchieveVO.setFirstAchieve(cuMemberAchieveExt.getOrderAchieve());
                        }
                    } else {
                        if (Objects.equals(CountryConstants.CHINA_COUNTRY, cuMemberAchieveExt.getPkSettleCountry())) {
                            memberMonthAchieveVO.setRepurchaseAchieve(ComputeUtil.computeMultiply(cuMemberAchieveExt.getOrderAchieve(), cuMemberAchieveExt.getOutExchangeRate()));
                        } else {
                            memberMonthAchieveVO.setRepurchaseAchieve(cuMemberAchieveExt.getOrderAchieve());
                        }
                    }
                    memberMonthAchieveList.add(memberMonthAchieveVO);
                }
                TableDataInfo tableDataInfo = getDataTable(cuMemberAchieveExtList);
                tableDataInfo.setRows(memberMonthAchieveList);
                return tableDataInfo;
            }
        }
        return getDataTable(memberMonthAchieveList);
    }

    /**
     * 查询当时时间如果每月是第一天则不展示本月
     *
     * @return
     */
    @GetMapping("/get-data-info")
    public AjaxResult getDataInfo() {
        Date date = DateUtils.beforeDate(1, ChronoUnit.DAYS, DateUtils.currentDate());
        DateUtils.parseDateToFormat(DateUtils.YYYY_MM_DD, date);
        return AjaxResult.success();
    }
}
