package com.hzs.report.member.controller.manage;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.hzs.common.core.annotation.AccessPermissions;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.constant.EnumsPrefixConstants;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.enums.*;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.core.utils.StringUtils;
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.report.member.CuMemberPerk;
import com.hzs.common.domain.report.member.ext.CuMemberPerkDetailMemberExt;
import com.hzs.common.domain.report.member.ext.CuMemberPerkExt;
import com.hzs.common.domain.sale.ext.SaOrderExt;
import com.hzs.common.domain.sale.ext.SaOrderItemsExt;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.common.service.ITransactionCommonService;
import com.hzs.report.member.param.MemberPerkQueryParam;
import com.hzs.report.member.service.ICuMemberPerkDetailMemberService;
import com.hzs.report.member.service.ICuMemberPerkDetailOrderService;
import com.hzs.report.member.service.ICuMemberPerkService;
import com.hzs.report.member.vo.MemberPerkDetailOrderVO;
import com.hzs.report.member.vo.MemberPerkQueryVO;
import com.hzs.system.base.ICurrencyServiceApi;
import com.hzs.system.base.dto.CurrencyDTO;
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.util.*;

/**
 * @Description: 会员补贴配置控制器
 * @Author: jiang chao
 * @Time: 2024/4/22 16:31
 * @Classname: CuMemberPerkController
 * @PackageName: com.hzs.report.member.controller.manage
 */
@RestController
@RequestMapping("/manager/member-perk")
public class CuMemberPerkController extends BaseController {

    @Autowired
    private ICuMemberPerkService iCuMemberPerkService;
    @Autowired
    private ICuMemberPerkDetailMemberService iCuMemberPerkDetailMemberService;
    @Autowired
    private ICuMemberPerkDetailOrderService iCuMemberPerkDetailOrderService;
    @Autowired
    private ITransactionCommonService iTransactionCommonService;

    @DubboReference
    ICurrencyServiceApi iCurrencyServiceApi;

    /**
     * 补贴配置列表
     *
     * @param param 查询参数
     * @return
     */
    @AccessPermissions("MemberSubsidyConfig")
    @Log(module = EOperationModule.SPECIAL_BUSINESS, business = EOperationBusiness.MEMBER_PERK, method = EOperationMethod.SELECT)
    @GetMapping("/list")
    public TableDataInfo list(MemberPerkQueryParam param) {
        DateUtils.handTimeStartAndEnd(param.getCreationTime());

        // 返回结果
        List<MemberPerkQueryVO> resultList = new ArrayList<>();

        startPage();
        List<CuMemberPerkExt> list = iCuMemberPerkService.queryList(param, SecurityUtils.getPkCountry());
        if (CollectionUtil.isNotEmpty(list)) {
            // 当前时间
            Date nowDate = new Date();
            // 获取汇率
            CurrencyDTO currencyDTO = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry()).getData();

            for (CuMemberPerkExt cuMemberPerkExt : list) {
                // 处理返回数据
                MemberPerkQueryVO memberPerkQueryVO = BeanUtil.copyProperties(cuMemberPerkExt, MemberPerkQueryVO.class);

                // 考核类型（EAchievementType）
                if (EAchievementType.FIRST_PURCHASE.getValue() == cuMemberPerkExt.getCheckType()) {
                    // 首购
                    // 实际金额、业绩
                    memberPerkQueryVO.setRealAmount(cuMemberPerkExt.getFirstAmount());
                    memberPerkQueryVO.setRealAchieve(cuMemberPerkExt.getFirstAchieve());
                    // 去重金额、业绩
                    memberPerkQueryVO.setDistinctAmount(cuMemberPerkExt.getDistinctFirstAmount());
                    memberPerkQueryVO.setDistinctAchieve(cuMemberPerkExt.getDistinctFirstAchieve());
                } else if (EAchievementType.REPURCHASE.getValue() == cuMemberPerkExt.getCheckType()) {
                    // 复购
                    // 实际金额、业绩
                    memberPerkQueryVO.setRealAmount(cuMemberPerkExt.getRepurchaseAmount());
                    memberPerkQueryVO.setRealAchieve(cuMemberPerkExt.getRepurchaseAchieve());
                    // 去重金额、业绩
                    memberPerkQueryVO.setDistinctAmount(cuMemberPerkExt.getDistinctRepurchaseAmount());
                    memberPerkQueryVO.setDistinctAchieve(cuMemberPerkExt.getDistinctRepurchaseAchieve());
                } else {
                    // 全部
                    // 实际金额、业绩
                    memberPerkQueryVO.setRealAmount(cuMemberPerkExt.getFirstAmount().add(cuMemberPerkExt.getRepurchaseAmount()));
                    memberPerkQueryVO.setRealAchieve(cuMemberPerkExt.getFirstAchieve().add(cuMemberPerkExt.getRepurchaseAchieve()));
                    // 去重金额、业绩
                    memberPerkQueryVO.setDistinctAmount(cuMemberPerkExt.getDistinctFirstAmount().add(cuMemberPerkExt.getDistinctRepurchaseAmount()));
                    memberPerkQueryVO.setDistinctAchieve(cuMemberPerkExt.getDistinctFirstAchieve().add(cuMemberPerkExt.getDistinctRepurchaseAchieve()));
                }

                // 最终金额（实际金额 - 去重金额）
                memberPerkQueryVO.setFinalAmount(memberPerkQueryVO.getRealAmount().subtract(memberPerkQueryVO.getDistinctAmount()));
                // 最终业绩（实际业绩 - 去重业绩）
                memberPerkQueryVO.setFinalAchieve(memberPerkQueryVO.getRealAchieve().subtract(memberPerkQueryVO.getDistinctAchieve()));

                if (EYesNo.YES.getIntValue() == cuMemberPerkExt.getDeductionPolicy()) {
                    // 扣除政策币
                    memberPerkQueryVO.setFinalAmount(memberPerkQueryVO.getFinalAmount().subtract(cuMemberPerkExt.getUsedPolicy()));
                }
                if (EYesNo.YES.getIntValue() == cuMemberPerkExt.getDeductionRepurchase()) {
                    // 扣除复购券
                    memberPerkQueryVO.setFinalAmount(memberPerkQueryVO.getFinalAmount().subtract(cuMemberPerkExt.getUsedRepurchase()));
                }

                // 状态（EPerkStatus）
                if (EPerkStatus.RETURNED.getValue() == cuMemberPerkExt.getStatus()) {
                    // 已反补
                    memberPerkQueryVO.setStatusVal(EPerkStatus.RETURNED.getLabel());
                    memberPerkQueryVO.setStatus(EPerkStatus.RETURNED.getValue());
                } else {
                    // 未反补
                    if (nowDate.compareTo(cuMemberPerkExt.getCalculateStartDate()) < 0) {
                        // 当前时间 小于 统计开始时间，为【未开始】
                        memberPerkQueryVO.setStatusVal(EPerkStatus.NOT_START.getLabel());
                        memberPerkQueryVO.setStatus(EPerkStatus.NOT_START.getValue());
                    } else if (nowDate.compareTo(cuMemberPerkExt.getCalculateStartDate()) >= 0
                            && nowDate.compareTo(cuMemberPerkExt.getCalculateEndDate()) <= 0) {
                        // 当前时间 大于等于 统计开始时间，小于等于 统计结束时间，为【进行中】
                        memberPerkQueryVO.setStatusVal(EPerkStatus.IN_PROGRESS.getLabel());
                        memberPerkQueryVO.setStatus(EPerkStatus.IN_PROGRESS.getValue());
                    } else {
                        // 【未反补】
                        memberPerkQueryVO.setStatusVal(EPerkStatus.NOT_RETURN.getLabel());
                        memberPerkQueryVO.setStatus(EPerkStatus.NOT_RETURN.getValue());
                    }
                }

                // 实际业绩、去重业绩、最终业绩汇率处理
                memberPerkQueryVO.setRealAchieve(memberPerkQueryVO.getRealAchieve().multiply(currencyDTO.getInExchangeRate()));
                memberPerkQueryVO.setDistinctAchieve(memberPerkQueryVO.getDistinctAchieve().multiply(currencyDTO.getInExchangeRate()));
                memberPerkQueryVO.setFinalAchieve(memberPerkQueryVO.getFinalAchieve().multiply(currencyDTO.getInExchangeRate()));

                resultList.add(memberPerkQueryVO);
            }
        }

        TableDataInfo tableDataInfo = getDataTable(list);
        tableDataInfo.setRows(resultList);
        return tableDataInfo;
    }

    /**
     * 补贴配置导出
     *
     * @param response
     * @param param    查询参数
     */
    @Log(module = EOperationModule.SPECIAL_BUSINESS, business = EOperationBusiness.MEMBER_PERK, method = EOperationMethod.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberPerkQueryParam param) {
        DateUtils.handTimeStartAndEnd(param.getCreationTime());

        // 返回结果
        List<MemberPerkQueryVO> resultList = new ArrayList<>();
        List<CuMemberPerkExt> list = iCuMemberPerkService.queryList(param, SecurityUtils.getPkCountry());
        if (CollectionUtil.isNotEmpty(list)) {
            // 当前时间
            Date nowDate = new Date();
            // 获取汇率
            CurrencyDTO currencyDTO = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry()).getData();

            // 获取需要翻译的枚举翻译
            Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EYesNo.values(), EAchievementType.values());

            for (CuMemberPerkExt cuMemberPerkExt : list) {
                // 处理返回数据
                MemberPerkQueryVO memberPerkQueryVO = BeanUtil.copyProperties(cuMemberPerkExt, MemberPerkQueryVO.class);

                // 考核类型（EAchievementType）
                if (EAchievementType.FIRST_PURCHASE.getValue() == cuMemberPerkExt.getCheckType()) {
                    // 首购
                    // 实际金额、业绩
                    memberPerkQueryVO.setRealAmount(cuMemberPerkExt.getFirstAmount());
                    memberPerkQueryVO.setRealAchieve(cuMemberPerkExt.getFirstAchieve());
                    // 去重金额、业绩
                    memberPerkQueryVO.setDistinctAmount(cuMemberPerkExt.getDistinctFirstAmount());
                    memberPerkQueryVO.setDistinctAchieve(cuMemberPerkExt.getDistinctFirstAchieve());
                } else if (EAchievementType.REPURCHASE.getValue() == cuMemberPerkExt.getCheckType()) {
                    // 复购
                    // 实际金额、业绩
                    memberPerkQueryVO.setRealAmount(cuMemberPerkExt.getRepurchaseAmount());
                    memberPerkQueryVO.setRealAchieve(cuMemberPerkExt.getRepurchaseAchieve());
                    // 去重金额、业绩
                    memberPerkQueryVO.setDistinctAmount(cuMemberPerkExt.getDistinctRepurchaseAmount());
                    memberPerkQueryVO.setDistinctAchieve(cuMemberPerkExt.getDistinctRepurchaseAchieve());
                } else {
                    // 全部
                    // 实际金额、业绩
                    memberPerkQueryVO.setRealAmount(cuMemberPerkExt.getFirstAmount().add(cuMemberPerkExt.getRepurchaseAmount()));
                    memberPerkQueryVO.setRealAchieve(cuMemberPerkExt.getFirstAchieve().add(cuMemberPerkExt.getRepurchaseAchieve()));
                    // 去重金额、业绩
                    memberPerkQueryVO.setDistinctAmount(cuMemberPerkExt.getDistinctFirstAmount().add(cuMemberPerkExt.getDistinctRepurchaseAmount()));
                    memberPerkQueryVO.setDistinctAchieve(cuMemberPerkExt.getDistinctFirstAchieve().add(cuMemberPerkExt.getDistinctRepurchaseAchieve()));
                }

                // 最终金额（实际金额 - 去重金额）
                memberPerkQueryVO.setFinalAmount(memberPerkQueryVO.getRealAmount().subtract(memberPerkQueryVO.getDistinctAmount()));
                // 最终业绩（实际业绩 - 去重业绩）
                memberPerkQueryVO.setFinalAchieve(memberPerkQueryVO.getRealAchieve().subtract(memberPerkQueryVO.getDistinctAchieve()));

                if (EYesNo.YES.getIntValue() == cuMemberPerkExt.getDeductionPolicy()) {
                    // 扣除政策币
                    memberPerkQueryVO.setFinalAmount(memberPerkQueryVO.getFinalAmount().subtract(cuMemberPerkExt.getUsedPolicy()));
                }
                if (EYesNo.YES.getIntValue() == cuMemberPerkExt.getDeductionRepurchase()) {
                    // 扣除复购券
                    memberPerkQueryVO.setFinalAmount(memberPerkQueryVO.getFinalAmount().subtract(cuMemberPerkExt.getUsedRepurchase()));
                }

                // 状态（EPerkStatus）
                if (EPerkStatus.RETURNED.getValue() == cuMemberPerkExt.getStatus()) {
                    // 已反补
                    memberPerkQueryVO.setStatusVal(EPerkStatus.RETURNED.getLabel());
                } else {
                    // 未反补
                    if (nowDate.compareTo(cuMemberPerkExt.getCalculateStartDate()) < 0) {
                        // 当前时间 小于 统计开始时间，为【未开始】
                        memberPerkQueryVO.setStatusVal(EPerkStatus.NOT_START.getLabel());
                    } else if (nowDate.compareTo(cuMemberPerkExt.getCalculateStartDate()) >= 0
                            && nowDate.compareTo(cuMemberPerkExt.getCalculateEndDate()) <= 0) {
                        // 当前时间 大于等于 统计开始时间，小于等于 统计结束时间，为【进行中】
                        memberPerkQueryVO.setStatusVal(EPerkStatus.IN_PROGRESS.getLabel());
                    } else {
                        // 【未反补】
                        memberPerkQueryVO.setStatusVal(EPerkStatus.NOT_RETURN.getLabel());
                    }
                }

                memberPerkQueryVO.setCheckTypeVal(transactionMap.get(EnumsPrefixConstants.ACHIEVEMENT_TYPE + cuMemberPerkExt.getCheckType()));
                memberPerkQueryVO.setCheckAmountVal(transactionMap.get(EnumsPrefixConstants.YES_NO + cuMemberPerkExt.getCheckAmount()));
                memberPerkQueryVO.setCheckAchieveVal(transactionMap.get(EnumsPrefixConstants.YES_NO + cuMemberPerkExt.getCheckAchieve()));
                memberPerkQueryVO.setContainCabinVal(transactionMap.get(EnumsPrefixConstants.YES_NO + cuMemberPerkExt.getContainCabin()));
                memberPerkQueryVO.setDeductionPolicyVal(transactionMap.get(EnumsPrefixConstants.YES_NO + cuMemberPerkExt.getDeductionPolicy()));
                memberPerkQueryVO.setDeductionRepurchaseVal(transactionMap.get(EnumsPrefixConstants.YES_NO + cuMemberPerkExt.getDeductionRepurchase()));
                memberPerkQueryVO.setDeduplicationVal(transactionMap.get(EnumsPrefixConstants.YES_NO + cuMemberPerkExt.getDeduplication()));

                // 实际业绩、去重业绩、最终业绩汇率处理
                memberPerkQueryVO.setRealAchieve(memberPerkQueryVO.getRealAchieve().multiply(currencyDTO.getInExchangeRate()));
                memberPerkQueryVO.setDistinctAchieve(memberPerkQueryVO.getDistinctAchieve().multiply(currencyDTO.getInExchangeRate()));
                memberPerkQueryVO.setFinalAchieve(memberPerkQueryVO.getFinalAchieve().multiply(currencyDTO.getInExchangeRate()));

                resultList.add(memberPerkQueryVO);
            }
        }

        ExcelUtil<MemberPerkQueryVO> util = new ExcelUtil<>(MemberPerkQueryVO.class);
        util.exportExcel(response, resultList, "会员补贴配置");
    }

    /**
     * 补贴配置详情
     *
     * @param pkId 补贴配置ID
     * @return
     */
    @GetMapping("/detail/{pkId}")
    public AjaxResult detail(@PathVariable("pkId") Long pkId) {
        CuMemberPerkExt cuMemberPerkExt = iCuMemberPerkService.queryDetail(pkId);
        MemberPerkQueryVO memberPerkQueryVO = BeanUtil.copyProperties(cuMemberPerkExt, MemberPerkQueryVO.class);
        return AjaxResult.success(memberPerkQueryVO);
    }

    /**
     * 保存补贴配置
     *
     * @param cuMemberPerkList 补贴配置列表
     * @return
     */
    @Log(module = EOperationModule.SPECIAL_BUSINESS, business = EOperationBusiness.MEMBER_PERK, method = EOperationMethod.CREATE)
    @PostMapping("/save")
    public AjaxResult save(@RequestBody List<CuMemberPerk> cuMemberPerkList) {
        if (CollectionUtil.isEmpty(cuMemberPerkList)) {
            return AjaxResult.error("补贴配置数据不能为空");
        }
        return toAjax(iCuMemberPerkService.saveBatchData(cuMemberPerkList, SecurityUtils.getUserId(), SecurityUtils.getPkCountry()));
    }

    /**
     * 更新补贴配置
     *
     * @param cuMemberPerk 补贴配置列表
     * @return
     */
    @PostMapping("/update")
    @Log(module = EOperationModule.SPECIAL_BUSINESS, business = EOperationBusiness.MEMBER_PERK, method = EOperationMethod.UPDATE)
    public AjaxResult update(@RequestBody CuMemberPerk cuMemberPerk) {
        if (null == cuMemberPerk.getPkId()) {
            return AjaxResult.error("补贴配置数据不能为空");
        }
        return toAjax(iCuMemberPerkService.updateData(cuMemberPerk, SecurityUtils.getUserId()));
    }

    /**
     * 补贴配置删除
     *
     * @param pkIdList 补贴配置ID列表
     * @return
     */
    @DeleteMapping("/delete")
    @Log(module = EOperationModule.SPECIAL_BUSINESS, business = EOperationBusiness.MEMBER_PERK, method = EOperationMethod.DELETE)
    public AjaxResult delete(@RequestParam List<Long> pkIdList) {
        if (CollectionUtil.isEmpty(pkIdList)) {
            // 缺少参数
            return AjaxResult.error("缺少参数");
        }
        iCuMemberPerkService.deletePerkData(pkIdList, SecurityUtils.getUserId());
        return AjaxResult.success();
    }

    /**
     * 补贴配置反补
     *
     * @param pkId 补贴配置ID
     * @return
     */
    @Log(module = EOperationModule.SPECIAL_BUSINESS, business = EOperationBusiness.MEMBER_PERK, method = EOperationMethod.CONFIRM)
    @PostMapping("/returned/{pkId}")
    public AjaxResult returned(@PathVariable("pkId") Long pkId) {
        UpdateWrapper<CuMemberPerk> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq(SystemFieldConstants.PK_ID, pkId);
        updateWrapper.set("STATUS", EPerkStatus.RETURNED.getValue());
        updateWrapper.set(SystemFieldConstants.PK_MODIFIED, SecurityUtils.getUserId());
        updateWrapper.set(SystemFieldConstants.MODIFIED_TIME, new Date());
        return toAjax(iCuMemberPerkService.update(updateWrapper));
    }

    /**
     * 补贴配置去重会员明细
     *
     * @param pkId 补贴配置ID
     * @return
     */
    @GetMapping("/detail-member/{pkId}")
    public TableDataInfo detailMember(@PathVariable("pkId") Long pkId) {
        startPage();
        return getDataTable(iCuMemberPerkDetailMemberService.queryMemberList(pkId));
    }

    /**
     * 补贴配置去重会员明细导出
     *
     * @param response
     * @param cuMemberPerk 导出入参
     */
    @PostMapping("/detail-member-export")
    public void export(HttpServletResponse response, CuMemberPerk cuMemberPerk) {
        List<CuMemberPerkDetailMemberExt> resultList = iCuMemberPerkDetailMemberService.queryMemberList(cuMemberPerk.getPkId());
        ExcelUtil<CuMemberPerkDetailMemberExt> util = new ExcelUtil<>(CuMemberPerkDetailMemberExt.class);
        util.exportExcel(response, resultList, "明细导出");
    }

    /**
     * 补贴配置去重订单明细
     *
     * @param pkId 补贴配置ID
     * @return
     */
    @GetMapping("/detail-order/{pkId}")
    public TableDataInfo detailOrder(@PathVariable("pkId") Long pkId) {
        List<MemberPerkDetailOrderVO> resultList = new ArrayList<>();

        startPage();
        List<SaOrderExt> saOrderExtList = iCuMemberPerkDetailOrderService.queryOrderList(pkId);
        if (StringUtils.isNotEmpty(saOrderExtList)) {
            // 获取汇率
            CurrencyDTO currencyDTO = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry()).getData();

            for (SaOrderExt saOrderExt : saOrderExtList) {
                for (SaOrderItemsExt saOrderItemsExt : saOrderExt.getOrderItemsExtList()) {
                    MemberPerkDetailOrderVO memberPerkDetailOrderVO = BeanUtil.copyProperties(saOrderExt, MemberPerkDetailOrderVO.class);
                    memberPerkDetailOrderVO.setOrderAchieve(memberPerkDetailOrderVO.getOrderAchieve().multiply(currencyDTO.getInExchangeRate()));
                    memberPerkDetailOrderVO.setProductCode(saOrderItemsExt.getProductCode());
                    memberPerkDetailOrderVO.setProductName(saOrderItemsExt.getProductName());
                    memberPerkDetailOrderVO.setQuantity(saOrderItemsExt.getQuantity());
                    memberPerkDetailOrderVO.setSpecsName(saOrderItemsExt.getSpecsName());
                    resultList.add(memberPerkDetailOrderVO);
                }
            }
        }

        TableDataInfo tableDataInfo = getDataTable(saOrderExtList);
        tableDataInfo.setRows(resultList);
        return tableDataInfo;
    }

    /**
     * 补贴配置去重订单导出
     *
     * @param response
     * @param cuMemberPerk 导出入参
     */
    @PostMapping("/detail-order-export/{pkId}")
    public void detailOrderExport(HttpServletResponse response, CuMemberPerk cuMemberPerk) {
        List<MemberPerkDetailOrderVO> resultList = new ArrayList<>();

        startPage();
        List<SaOrderExt> saOrderExtList = iCuMemberPerkDetailOrderService.queryOrderList(cuMemberPerk.getPkId());
        if (StringUtils.isNotEmpty(saOrderExtList)) {
            // 获取汇率
            CurrencyDTO currencyDTO = iCurrencyServiceApi.getCurrency(SecurityUtils.getPkCountry()).getData();
            // 获取需要翻译的枚举翻译
            Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(EDelFlag.values(), EOrderType.values());

            for (SaOrderExt saOrderExt : saOrderExtList) {
                for (SaOrderItemsExt saOrderItemsExt : saOrderExt.getOrderItemsExtList()) {
                    MemberPerkDetailOrderVO memberPerkDetailOrderVO = BeanUtil.copyProperties(saOrderExt, MemberPerkDetailOrderVO.class);
                    memberPerkDetailOrderVO.setOrderAchieve(memberPerkDetailOrderVO.getOrderAchieve().multiply(currencyDTO.getInExchangeRate()));
                    memberPerkDetailOrderVO.setOrderTypeVal(transactionMap.get(EnumsPrefixConstants.ORDER_TYPE + saOrderExt.getOrderType()));
                    memberPerkDetailOrderVO.setDelFlagVal(transactionMap.get(EnumsPrefixConstants.DEL_FLAG + saOrderExt.getDelFlag()));
                    memberPerkDetailOrderVO.setProductCode(saOrderItemsExt.getProductCode());
                    memberPerkDetailOrderVO.setProductName(saOrderItemsExt.getProductName());
                    memberPerkDetailOrderVO.setQuantity(saOrderItemsExt.getQuantity());
                    memberPerkDetailOrderVO.setSpecsName(saOrderItemsExt.getSpecsName());
                    resultList.add(memberPerkDetailOrderVO);
                }
            }
        }

        ExcelUtil<MemberPerkDetailOrderVO> util = new ExcelUtil<>(MemberPerkDetailOrderVO.class);
        util.exportExcel(response, resultList, "去重订单导出");
    }

}
