package com.crm.manager.controller;

import com.crm.login.rely.backend.controller.BaseLoginController;
import com.crm.manager.dto.export.*;
import com.crm.manager.entity.excel.CardNumberExcelEntity;
import com.crm.manager.service.CommonService;
import com.crm.manager.service.ucard.WasabiCardFeignService;
import com.crm.rely.backend.core.constant.Constants;
import com.crm.rely.backend.core.dto.base.*;
import com.crm.rely.backend.core.dto.ucard.*;
import com.crm.rely.backend.core.dto.ucard.vaultody.VaultodyDepositAddressDto;
import com.crm.rely.backend.core.dto.wasabi.*;
import com.crm.rely.backend.core.entity.base.*;
import com.crm.rely.backend.core.entity.custom.info.InfoEntity;
import com.crm.rely.backend.core.entity.ucard.*;
import com.crm.rely.backend.core.entity.ucard.crypto.currency.vaultody.VaultodyDepositAddressPageEntity;
import com.crm.rely.backend.core.entity.ucard.crypto.currency.vaultody.VaultodyResetDepositAddressEntity;
import com.crm.rely.backend.core.entity.wasabi.*;
import com.crm.rely.backend.core.enums.*;
import com.crm.rely.backend.exception.ServiceException;
import com.crm.rely.backend.util.*;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 银行卡服务接口
 */
@Slf4j
@RestController
@RequestMapping("/wasabi")
public class WasabiCardController extends BaseLoginController {

    @Autowired
    private WasabiCardFeignService wasabiCardFeignService;
    @Autowired
    private CommonService commonService;


    /**
     * 获取卡片类型列表
     */
    @PostMapping("/card/types/page")
    public ResultWithPagerDto<CardTypeDto> getCardTypePageList(@RequestBody CardTypePageEntity entity) throws ServiceException {
        return wasabiCardFeignService.getCardTypePageList(entity);
    }

    /**
     * 更新卡片类型列表
     */
    @PostMapping("/card/types")
    public BaseResultDto getCardTypes() throws ServiceException {
        return wasabiCardFeignService.getCardTypes();
    }

    /**
     * 更新卡类型配置
     */
    @PostMapping("/card/type/config/update")
    public BaseResultDto updateCardTypeConfig(@RequestBody CardTypeConfigUpdateEntity entity) throws ServiceException {
        return wasabiCardFeignService.updateCardTypeConfig(entity);
    }

    /**
     * 商户用户分页列表
     */
    @PostMapping("/merchant/user/page")
    public ResultWithPagerDto<MerchantUserDto> getMerchantUserPageList(@RequestBody MerchantUserPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getMerchantUserPageList(entity);
    }

    /**
     * 商户用户注册
     */
    @PostMapping("/merchant/user/register")
    public BaseResultDto registerMerchantUser(@RequestBody @Validated CardMerchantUserEntity request,InfoEntity infoEntity) throws ServiceException {
        request.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.registerMerchantUser(request);
    }

    /**
     * 更新用户邮寄地址
     */
    @PostMapping("/merchant/user/address/update")
    public BaseResultDto updateUserMailingAddress(@RequestBody WasabiSaveUserMailingAddressEntity request) throws ServiceException {
        return wasabiCardFeignService.updateUserMailingAddress(request);
    }

    /**
     * 更新商户用户信息
     */
    @PostMapping("/merchant/user/update")
    public BaseResultDto updateMerchantUser(@RequestBody @Validated CardMerchantUserEntity request) throws ServiceException {
        return wasabiCardFeignService.updateMerchantUser(request);
    }

    /**
     * 配置用户汇率
     */
    @PostMapping("/merchant/user/rate/config")
    public BaseResultDto cardUserRateConfig(@RequestBody CardUserRateConfigEntity request) throws ServiceException {
        return wasabiCardFeignService.cardUserRateConfig(request);
    }

    /**
     * 获取kyc认证分页列表
     */
    @PostMapping("/merchant/kyc/page")
    ResultWithPagerDto<CardKycStatusDto> getKycPageList(@RequestBody CardKycStatusPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getKycPageList(entity);
    }

    /**
     * 手动审核KYC认证
     */
    @PostMapping("/merchant/kyc/manual/submit")
    public BaseResultDto manualSubmitKyc(@RequestBody CardKycApproveEntity entity) throws ServiceException {
        return wasabiCardFeignService.manualSubmitKyc(entity);
    }

    /**
     * 申请开卡
     */
    @PostMapping("/card/apply")
    public BaseResultDto applyCard(@RequestBody CardApplyEntity request) throws ServiceException {
        return wasabiCardFeignService.applyCard(request);
    }

    /**
     * 开卡申请审批
     */
    @PostMapping("/card/apply/approve")
    public BaseResultDto cardApplyApprove(@RequestBody CardApplyApproveEntity request) throws Exception {
        return wasabiCardFeignService.cardApplyApprove(request);
    }

    /**
     * 查询开卡进度
     */
    @PostMapping("/card/apply/progress")
    public BaseResultDto queryApplyProgress(@RequestBody CardApplyProgressEntity request) throws ServiceException {
        return wasabiCardFeignService.queryApplyProgress(request);
    }

    /**
     * 获取卡片申请列表
     */
    @PostMapping("/card/apply/page")
    public ResultWithPagerDto<CardApplyDto> getCardApplyPageList(@RequestBody CardApplyPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getCardApplyPageList(entity);
    }

    /**
     * 获取卡片申请详情
     */
    @PostMapping("/card/apply/details")
    public BaseResultDto cardApplyDetails(@RequestBody BaseEntity entity) throws ServiceException {
        return wasabiCardFeignService.cardApplyDetails(entity);
    }

    /**
     * 获取卡片列表
     */
    @PostMapping("/card/page")
    public ResultWithPagerDto<UcardCardDto> getCardPageList(@RequestBody CardPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getCardPageList(entity);
    }

    /**
     * 银行卡激活
     */
    @PostMapping("/card/activate")
    public BaseResultDto<WasabiActiveCardDto> activateCard(@RequestBody @Validated WasabiActiveCardEntity request) throws ServiceException {
        return wasabiCardFeignService.activateCard(request);
    }

    /**
     * 银行卡充值
     */
    @PostMapping("/card/recharge")
    public BaseResultDto<WasabiDepositDto> rechargeCard(@RequestBody WasabiBalanceEntity request) throws ServiceException {
        return wasabiCardFeignService.rechargeCard(request);
    }

    /**
     * 银行卡充值审批
     */
    @PostMapping("/card/recharge/approve")
    public BaseResultDto rechargeCard(@RequestBody WasabiDepositApproveEntity request) throws Exception {
        return wasabiCardFeignService.rechargeCardApprove(request);
    }

    /**
     * 查询用户钱包余额
     */
    @PostMapping("/card/wallet/balance")
    public BaseResultDto<WalletBalanceDto> walletBalance(@RequestBody WalletBalanceEntity request) throws ServiceException {
        return wasabiCardFeignService.walletBalance(request);
    }

    /**
     * 获取用户钱包记录列表
     */
    @PostMapping("/card/wallet/record/page")
    public ResultWithPagerDto<CardWalletRecordDto> getCardWalletRecordPageList(@RequestBody CardWalletRecordPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getCardWalletRecordPageList(entity);
    }

    /**
     * 查询充值订单
     */
    @PostMapping("/card/recharge/order")
    public BaseResultDto queryRechargeOrder(@RequestBody CardRechargeOrderQueryEntity request) throws ServiceException {
        return wasabiCardFeignService.queryRechargeOrder(request);
    }

    /**
     * 查询充值记录
     */
    @PostMapping("/card/recharge/records")
    public BaseResultDto<CardRechargeOrderListDto> queryRechargeRecords(@RequestBody WasabiTransactionEntity entity) throws ServiceException {
        return wasabiCardFeignService.queryRechargeRecords(entity);
    }

    /**
     * 充值记录分页查询
     */
    @PostMapping("/card/recharge/page")
    public BaseReportResultDto<List<CardRechargeOrderDto>, CardRechargeOrderSumDto> queryRechargePageList(@RequestBody CardRechargePageEntity entity) throws ServiceException {
        return wasabiCardFeignService.queryRechargePageList(entity);
    }

    /**
     * 查询卡片余额
     */
    @PostMapping("/card/balance")
    public BaseResultDto<WasabiBalanceInfoDto> queryCardBalance(@RequestBody WasabiBalanceInfoEntity request) throws ServiceException {
        return wasabiCardFeignService.queryCardBalance(request);
    }

    /**
     * 调整卡片余额
     */
    @PostMapping("/card/wallet/balance/update")
    public BaseResultDto updateBalance(@RequestBody WasabiUpdateBalanceEntity request) throws ServiceException {
        return wasabiCardFeignService.updateBalance(request);
    }

    /**
     * 找回密码
     */
    @PostMapping("/card/password/reset")
    public BaseResultDto resetPassword(@RequestBody WasabiUpdatePinEntity entity) throws ServiceException {
        return wasabiCardFeignService.resetPassword(entity);
    }

    /**
     * 查询交易记录分页列表
     */
    @PostMapping("/card/transac/page")
    public ResultWithPagerDto<CardTransacOrderDto> getTransactionPageList(@RequestBody CardTransacOrderPageEntity request,InfoEntity infoEntity) throws ServiceException {
        request.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getTransactionPageList(request);
    }

    /**
     * 冻结卡片
     */
    @PostMapping("/card/freeze")
    public BaseResultDto freezeCard(@RequestBody WasabiFreezeAndUnfreezeEntity request) throws ServiceException {
        return wasabiCardFeignService.freezeCard(request);
    }

    /**
     * 解冻卡片
     */
    @PostMapping("/card/unfreeze")
    public BaseResultDto unfreezeCard(@RequestBody WasabiFreezeAndUnfreezeEntity request) throws ServiceException {
        return wasabiCardFeignService.unfreezeCard(request);
    }

    /**
     * 上传文件
     */
    @PostMapping("/upload/file")
    public BaseResultDto<String> uploadFile(@RequestParam(value = "file") MultipartFile file) throws Exception {
        String middlePath = "/wasabi";
        wasabiCardFeignService.validatedFile(file);
        String path = commonService.uploadFile(middlePath, file);

        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, path);
    }

    /**
     * 上传文件
     */
    @PostMapping("manager/upload/file")
    public BaseResultDto<String> managerUploadFile(@RequestParam(value = "file") MultipartFile file) throws Exception {
        String middlePath = "/wasabi";
        String path = commonService.uploadFile(middlePath, file);
        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, path);
    }

    /**
     * 查询国家和城市
     */
    @PostMapping("/card/country")
    public BaseResultDto getCardCountry(@RequestBody CardCountryEntity request) throws ServiceException {
        return wasabiCardFeignService.getCardCountry(request);
    }

    /**
     * 查询职业信息
     */
    @PostMapping("/card/occupation/list")
    public BaseResultDto getOccupationList() throws ServiceException {
        return wasabiCardFeignService.getOccupationList();
    }

    /**
     * 查询激活码
     */
    @PostMapping("/get/activation/code")
    public BaseResultDto<WasabiThird3dsTransactionDto> getActivationCode(@RequestBody WasabiThird3dsTransactionEntity entity) throws ServiceException {
        return wasabiCardFeignService.getActivationCode(entity);
    }

    /**
     * 卡信息刷新
     */
    @PostMapping("/card/info/refresh")
    public BaseResultDto refreshCardInfo(@RequestBody CardInfoRefreshEntity entity) throws ServiceException {
        return wasabiCardFeignService.refreshCardInfo(entity);
    }

    /**
     * 卡权限分页列表
     */
    @PostMapping("/card/permission/page")
    public ResultWithPagerDto<CardPermissionDto> queryPermissionPageList(@RequestBody CardPermissionPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.queryPermissionPageList(entity);
    }

    /**
     * 新增卡权限
     */
    @PostMapping("/card/permission/add")
    public BaseResultDto permissionAdd(@RequestBody CardPermissionAddEntity entity) throws ServiceException {
        return wasabiCardFeignService.permissionAdd(entity);
    }

    /**
     * 更新卡权限
     */
    @PostMapping("/card/permission/update")
    public BaseResultDto permissionUpdate(@RequestBody CardPermissionUpdateEntity entity) throws ServiceException {
        return wasabiCardFeignService.permissionUpdate(entity);
    }

    /**
     * 删除卡权限
     */
    @PostMapping("/card/permission/delete")
    public BaseResultDto permissionDelete(@RequestBody CardPermissionDeleteEntity entity) throws ServiceException {
        return wasabiCardFeignService.permissionDelete(entity);
    }

    /**
     * 操作记录分页列表
     */
    @PostMapping("/card/operate/page")
    public ResultWithPagerDto<CardOperateDto> queryOperatePageList(@RequestBody CardOperatePageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.queryOperatePageList(entity);
    }

    /**
     * kyc认证详情
     */
    @PostMapping("/kyc/status/single")
    public BaseResultDto kycStatusSingle(@RequestBody SingleLongEntity entity) throws ServiceException {
        return wasabiCardFeignService.kycStatusSingle(entity);
    }

    /**
     * 重新充值默认开卡金额
     */
    @PostMapping("/recharge/default/amount")
    public BaseResultDto rechargeDefaultAmount(@RequestBody CardRechargeDefaultAmountEntity entity) throws Exception {
        return wasabiCardFeignService.rechargeDefaultAmount(entity);
    }

    /**
     * 校验实体卡卡号是否使用过
     */
    @PostMapping("/card/number/verify")
    public BaseResultDto cardNumberVerify(@RequestBody @Validated CardNumberVerifyEntity entity) throws ServiceException {
        return wasabiCardFeignService.cardNumberVerify(entity);
//        return BaseResultDto.success();
    }

    /**
     * 手动上传证件照
     *
     * @param entity
     * @return
     */
    @PostMapping("/card/photo/manually")
    public BaseResultDto uploadCardPhotoManually(@RequestBody CardPhotoUploadManuallyEntity entity) throws ServiceException {
        return wasabiCardFeignService.uploadCardPhotoManually(entity);
    }

    /**
     * 卡扣款
     */
    @PostMapping("/card/withdraw")
    public BaseResultDto cardWithdraw(@RequestBody WasabiWithdrawEntity request) throws Exception {
        return wasabiCardFeignService.cardWithdraw(request);
    }

    /**
     * 销卡
     */
    @PostMapping("/card/cancel")
    public BaseResultDto cardCancel(@RequestBody WasabiCancelEntity request) throws Exception {
        return wasabiCardFeignService.cardCancel(request);
    }

    /**
     * 证件类型配置列表
     */
    @PostMapping("/card/id/type/config/list")
    public ResultWithPagerDto<CardIdTypeConfigDto> getCardIdTypeConfigList(@RequestBody CardIdTypeConfigPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getCardIdTypeConfigList(entity);
    }

    /**
     * 批量新增证件类型配置
     */
    @PostMapping("/card/id/type/config/add")
    public BaseResultDto batchAddCardIdTypeConfig(@RequestBody List<CardIdTypeConfigAddEntity> entitys) throws ServiceException {
        return wasabiCardFeignService.batchAddCardIdTypeConfig(entitys);
    }

    /**
     * 修改证件类型配置
     */
    @PostMapping("/card/id/type/config/update")
    public BaseResultDto updateCardIdTypeConfig(@RequestBody CardIdTypeConfigUpdateEntity entity) throws ServiceException {
        return wasabiCardFeignService.updateCardIdTypeConfig(entity);
    }

    /**
     * 删除证件类型配置
     */
    @PostMapping("/card/id/type/config/delete")
    public BaseResultDto deleteCardIdTypeConfig(@RequestBody BaseDeleteEntities entity) throws ServiceException {
        return wasabiCardFeignService.deleteCardIdTypeConfig(entity);
    }

    /**
     * 校验谷歌验证码查询cvv码
     */
    @PostMapping("/card/query/cvv")
    public BaseResultDto cardQueryCvv(@RequestBody CardVerifyGoogleCodeEntity entity, InfoEntity infoEntity) throws ServiceException {
        entity.setVerified(infoEntity.getVerified());
        entity.setSecretKey(infoEntity.getSecretKey());
        return wasabiCardFeignService.cardQueryCvv(entity);
    }

    /**
     * 根据卡号查询卡信息
     */
    @PostMapping("/card/info/query")
    public BaseResultDto queryCardInfoByCardNumber(@RequestBody CardInfoQueryEntity entity) throws ServiceException {
        return wasabiCardFeignService.queryCardInfoByCardNumber(entity);
    }

    /**
     * 实体卡卡号导入
     */
    @PostMapping("/card/number/import")
    public BaseResultDto cardNumberImport(@RequestParam("file") MultipartFile file) throws Exception {
        // 文件类型校验
        String fileName = file.getOriginalFilename();
        if (fileName != null && !fileName.toLowerCase().endsWith(".xlsx") && !fileName.toLowerCase().endsWith(".xls")) {
            return BaseResultDto.error("请上传Excel文件");
        }
        List<CardNumberExcelEntity> entities = EasyExcelUti.readExcel(file,
                new CardNumberExcelEntity(), 1, CardNumberExcelEntity.class);

        if (CollectionUtils.isEmpty(entities)) {
            return BaseResultDto.success();
        }
        // 验证是否为纯数字格式
        List<CardNumberAddEntity> entityList = entities.stream()
                .map(entity -> {
                    // 修剪空格
                    String cardNumber = entity.getCardNumber().trim();
                    return cardNumber;
                }).filter(StringUtils::isNumeric).map(cardNumber -> {
                    CardNumberAddEntity addEntity = new CardNumberAddEntity();
                    addEntity.setCardNumber(cardNumber);
                    return addEntity;
                }).collect(Collectors.toList());
        return wasabiCardFeignService.cardNumberImport(entityList);
    }

    /**
     * 卡号模版导出
     */
    @PostMapping("/card/number/template/export")
    public void cardNumberTemplateExport(HttpServletResponse response) throws Exception {
        List<CardNumberExportDto> dtos = Lists.newArrayList();
        ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_NUMBER_TEMPLATE"), dtos, CardNumberExportDto.class, response);
    }

    /**
     * 卡号列表
     */
    @PostMapping("/card/number/list")
    ResultWithPagerDto<CardNumberDto> queryCardNumberList(@RequestBody CardNumberPageEntity entity,InfoEntity infoEntity) throws ServiceException {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.queryCardNumberList(entity);
    }

    /**
     * 卡号下拉列表
     */
    @PostMapping("/card/number/dropdown")
    BaseResultDto queryCardNumberDropdown(@RequestBody CardNumberPageEntity entity) throws ServiceException {
        // 默认查询未使用的卡号
        entity.setStatus(1);
        return wasabiCardFeignService.queryCardNumberDropdown(entity);
    }

    /**
     * 修改卡号状态
     */
    @PostMapping("/card/number/update/status")
    BaseResultDto saveCardNumberStatus(@RequestBody CardNumberUpdateEntity entity) throws ServiceException {
        return wasabiCardFeignService.saveCardNumberStatus(entity);
    }

    /**
     * 删除实体卡卡号
     */
    @PostMapping("/card/number/delete")
    public BaseResultDto deleteCardNumber(@RequestBody BaseDeleteEntities entity) throws ServiceException {
        return wasabiCardFeignService.deleteCardNumber(entity);
    }

    /**
     * 用户列表导出
     *
     * @param entity:
     * @param response:
     * @return void
     */
    @RequestMapping("/merchant/user/list/export")
    public void merchantUserListExport(@RequestBody MerchantUserPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<MerchantUserDto>> resultDto = wasabiCardFeignService.merchantUserListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardMerchantUserListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardMerchantUserListExportDto dto = new CardMerchantUserListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    dto.setPhotoStatus((item.getPhotoStatus() != null && item.getPhotoStatus() == 1) ? "是" : "否");
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setBalance(item.getBalance() == null ? new BigDecimal(0) : item.getBalance());
                    dto.setIdType(CardIdTypeEnum.matchCode(item.getIdType()));
                    dto.setGender("M".equals(item.getGender()) ? "男" : "女");
                    dto.setCardFee(item.getCardFee() == null ? "" : String.valueOf(item.getCardFee()));
                    dto.setCardRechargeFeeRate(item.getCardRechargeFeeRate() == null ? "" : String.valueOf(item.getCardRechargeFeeRate()));
                    dto.setGlobalFeeRate(item.getGlobalFeeRate() == null ? "" : String.valueOf(item.getGlobalFeeRate()));
                    dto.setGlobalFixedFee(item.getGlobalFixedFee() == null ? "" : String.valueOf(item.getGlobalFixedFee()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("MERCHANT_USER_INFO"), dtos, CardMerchantUserListExportDto.class, response);
        }
    }

    /**
     * KYC认证列表导出
     *
     * @param entity:
     * @param response:
     * @return void
     */
    @RequestMapping("/merchant/kyc/list/export")
    public void merchantKycListExport(@RequestBody CardKycStatusPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardKycStatusDto>> resultDto = wasabiCardFeignService.merchantKycListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardMerchantKycListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardMerchantKycListExportDto dto = new CardMerchantKycListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setPhotoStatus((item.getPhotoStatus() != null && item.getPhotoStatus() == 1) ? "是" : "否");
                    if (item.getKycStatus() != null) {
                        switch (item.getKycStatus()) {
                            case 1:
                                dto.setKycStatus("待处理");
                                break;
                            case 2:
                                dto.setKycStatus("认证成功");
                                break;
                            case 3:
                                dto.setKycStatus("认证失败");
                                break;
                        }
                    } else {
                        dto.setKycStatus("待处理");
                    }
                    dto.setStatus(CardApproveStatusEnum.matchCode(item.getStatus()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("MERCHANT_KYC_INFO"), dtos, CardMerchantKycListExportDto.class, response);
        }
    }

    /**
     * 卡片申请列表导出
     */
    @RequestMapping("/card/apply/list/export")
    public void cardApplyListExport(@RequestBody CardApplyPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardApplyDto>> resultDto = wasabiCardFeignService.cardApplyListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardApplyListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardApplyListExportDto dto = new CardApplyListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    item.setMailingAreaCode(item.getMailingAreaCode() == null ? "" : item.getMailingAreaCode());
                    item.setMailingMobile(item.getMailingMobile() == null ? "" : item.getMailingMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setMailingMobile(item.getMailingAreaCode() + " " + item.getMailingMobile());
                    if (item.getStatus() != null){
                        dto.setStatus(CardStatusTypeEnum.matchCode(item.getStatus()));
                    } else {
                        dto.setStatus("待处理");
                    }
                    dto.setTradeStatus(CardTradeStatusEnum.matchCode(item.getTradeStatus(), item.getTradeType()));
                    dto.setApproveStatus(CardApproveStatusEnum.matchCode(item.getApproveStatus()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_APPLY_INFO"), dtos, CardApplyListExportDto.class, response);
        }
    }

    /**
     * 卡片列表导出
     */
    @RequestMapping("/card/list/export")
    public void cardListExport(@RequestBody CardPageEntity entity, InfoEntity infoEntity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<UcardCardDto>> resultDto = wasabiCardFeignService.cardListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardListExportDto dto = new CardListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setStatus(CardStatusTypeEnum.matchCode(item.getStatus()));
                    dto.setFreezeStatus(CardFreezeStatusEnum.matchCode(item.getFreezeStatus(), item.getFreezeType()));
                    dto.setBlockedStatus((item.getBlocked() != null && item.getBlocked()) ? "锁定" : "正常");
                    dto.setCancelStatus((CardStatusTypeEnum.matchCode(item.getCancelStatus())));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_INFO"), dtos, CardListExportDto.class, response);
        }
    }

    /**
     * 交易记录列表导出
     */
    @RequestMapping("/card/transac/record/export")
    public void cardTransacRecordExport(@RequestBody CardTransacOrderPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardTransacOrderDto>> resultDto = wasabiCardFeignService.cardTransacRecordExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardTransacRecordExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardTransacRecordExportDto dto = new CardTransacRecordExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getUserCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setTransactionTime(item.getTransactionTime() != null ? DateUtil.formatTimestamp(item.getTransactionTime()) : "");
                    dto.setStatus(CardTransacStatusEnum.matchCode(item.getStatus()));
                    dto.setType(CardTransacTypeEnum.matchCode(item.getType()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_TRANSAC_RECORD"), dtos, CardTransacRecordExportDto.class, response);
        }
    }

    /**
     * 钱包余额记录列表导出
     */
    @RequestMapping("/card/wallet/record/export")
    public void cardWalletRecordExport(@RequestBody CardWalletRecordPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardWalletRecordDto>> resultDto = wasabiCardFeignService.cardWalletRecordExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardWalletRecordExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardWalletRecordExportDto dto = new CardWalletRecordExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    switch (item.getStatus()) {
                        case 1:
                            dto.setStatus("处理中");
                            break;
                        case 2:
                            dto.setStatus("成功");
                            break;
                        case 3:
                            dto.setStatus("失败");
                            break;
                    }
                    dto.setType(CardWalletRecordTypeEnum.matchCode(item.getType()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_WALLET_RECORD"), dtos, CardWalletRecordExportDto.class, response);
        }
    }

    /**
     * 操作记录列表导出
     */
    @RequestMapping("/card/operate/record/export")
    public void cardOperateRecordExport(@RequestBody CardOperatePageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardOperateDto>> resultDto = wasabiCardFeignService.cardOperateRecordExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardOperateRecordExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardOperateRecordExportDto dto = new CardOperateRecordExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setOperateType(CardOperateTypeEnum.matchCode(item.getOperateType()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_OPERATE_RECORD"), dtos, CardOperateRecordExportDto.class, response);
        }
    }

    /**
     * 充值申请列表导出
     */
    @RequestMapping("/card/recharge/list/export")
    public void cardRechargeListExport(@RequestBody CardRechargePageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardRechargeOrderDto>> resultDto = wasabiCardFeignService.cardRechargeListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardRechargeListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardRechargeListExportDto dto = new CardRechargeListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setStatus(CardStatusTypeEnum.matchCode(item.getStatus()));
                    dto.setApproveStatus(CardApproveStatusEnum.matchCode(item.getApproveStatus()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_RECHARGE_RECORD"), dtos, CardRechargeListExportDto.class, response);
        }
    }

    /**
     * 速汇订单导出
     */
    @PostMapping("/global/order/list/export")
    public void globalOrderListExport(@RequestBody GlobalOrderPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<GlobalOrderDto>> resultDto = wasabiCardFeignService.globalOrderListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<GlobalOrderListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    GlobalOrderListExportDto dto = new GlobalOrderListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    if (item.getStatus() != null){
                        dto.setStatus(GlobalOrderStatusEnum.matchStatus(item.getStatus()));
                    } else {
                        dto.setStatus("待处理");
                    }
                    dto.setApproveStatus(CardApproveStatusEnum.matchCode(item.getApproveStatus()));
                    dto.setDeductionAccountStatus(GlobalOrderDeductionStatusEnum.matchStatus(item.getDeductionAccountStatus()));
                    dto.setTransactionTime(item.getCreateTime() != null ? DateUtil.formatTimestamp(item.getCreateTime()) : "");
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("GLOBAL_ORDER_LIST"), dtos, GlobalOrderListExportDto.class, response);
        }
    }

    /**
     * 加密货币交易记录导出
     */
    @PostMapping("/encrypted/wallet/transaction/list/export")
    public void encryptedWalletTransactionListExport(@RequestBody EncryptedWalletTransactionPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<EncryptedWalletTransactionDto>> resultDto = wasabiCardFeignService.encryptedWalletTransactionListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<EncryptedWalletTransactionListExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    EncryptedWalletTransactionListExportDto dto = new EncryptedWalletTransactionListExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    dto.setTokenName(item.getName());
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setDirection("incoming".equals(item.getDirection()) ? "转入" : "转出");
                    dto.setTimestamp(DateUtil.formatTimestamp(Long.valueOf(item.getTimestamp())));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("ENCRYPTED_WALLET_TRANSACTION_LIST_EXPORT"), dtos, EncryptedWalletTransactionListExportDto.class, response);
        }
    }

    /**
     * 上传视频
     */
    @PostMapping("/card/upload/video")
    public BaseResultDto cardFileUpload(@RequestParam(value = "file", required =
            false) MultipartFile file) throws Exception {
        String middlePath = "/wasabi/video";
        commonService.validatedVideo(file);
        String path = commonService.uploadFile(middlePath, file);

        return BaseResultDto.success(Constants.UPLOAD_SUCCESS, path);
    }


    /**
     * 添加文件记录
     */
    @PostMapping("/card/file/add")
    public BaseResultDto cardFileAdd(@RequestBody @Validated CardFileAddEntity entity) throws ServiceException {
        return wasabiCardFeignService.cardFileAdd(entity);
    }

    /**
     * 修改文件
     */
    @PostMapping("/card/file/update")
    public BaseResultDto cardFileUpdate(@RequestBody @Validated CardFileUpdateEntity entity) throws ServiceException {
        return wasabiCardFeignService.cardFileUpdate(entity);
    }

    /**
     * 删除文件
     */
    @PostMapping("/card/file/delete")
    public BaseResultDto cardFileDelete(@RequestBody BaseDeleteEntities entity) throws ServiceException {
        return wasabiCardFeignService.cardFileDelete(entity);
    }

    /**
     * 文件分页列表
     */
    @PostMapping("/card/file/search/list")
    public ResultWithPagerDto<CardFileDto> cardFileSearchList(@RequestBody CardFilePageEntity entity) throws ServiceException {
        return wasabiCardFeignService.cardFileSearchList(entity);
    }

    /**
     * 同步币种信息
     */
    @PostMapping("/global/currencies/save")
    public BaseResultDto saveAvailableCurrencies() throws ServiceException {
        return wasabiCardFeignService.saveAvailableCurrencies();
    }

    /**
     * 币种分页列表
     */
    @PostMapping("/global/currencies/list")
    ResultWithPagerDto<WasabiAvailableCurrenciesListDto> getCurrenciesPageList(@RequestBody GlobalCurrenciesPageListEntity entity,InfoEntity infoEntity) throws ServiceException{
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getCurrenciesPageList(entity);
    }

    /**
     * 支持的币种下拉列表
     */
    @PostMapping("/global/currencies/dropdown")
    public BaseResultDto getCurrenciesDropdown(@RequestBody GlobalCurrenciesDropdownEntity entity) throws ServiceException {
        return wasabiCardFeignService.getCurrenciesDropdown(entity);
    }

    /**
     * 币种字段和可选值列表
     */
    @PostMapping("/global/currencies/field/list")
    public BaseResultDto getCurrenciesFieldList(@RequestBody @Validated GlobalCurrenciesFieldListEntity entity) throws ServiceException {
        return wasabiCardFeignService.getCurrenciesFieldList(entity);
    }

    /**
     * 查询账户信息
     */
    @PostMapping("/card/account/dropdown")
    public BaseResultDto cardAccountDropdown(@RequestBody CardAccountDropdownEntity entity) throws ServiceException {
        return wasabiCardFeignService.cardAccountDropdown(entity);
    }

    /**
     * 创建交易订单
     */
    @PostMapping("/global/create/order")
    public BaseResultDto globalCreateOrder(@RequestBody GlobalCreateOrderEntity entity) throws Exception {
        return wasabiCardFeignService.globalCreateOrder(entity);
    }

    /**
     * 速汇订单分页列表
     */
    @PostMapping("/global/order/page/list")
    public ResultWithPagerDto<GlobalOrderDto> globalOrderPageList(@RequestBody GlobalOrderPageEntity entity,InfoEntity infoEntity) throws Exception {
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.globalOrderPageList(entity);
    }

    /**
     * 速汇订单审批
     */
    @PostMapping("/global/order/approve")
    public BaseResultDto globalOrderApprove(@RequestBody GlobalOrderApproveEntity entity) throws Exception {
        return wasabiCardFeignService.globalOrderApprove(entity);
    }

    /**
     * 查询已认证用户列表
     */
    @PostMapping("/card/query/user/list")
    public BaseResultDto queryUcardUserList() throws ServiceException {
        return wasabiCardFeignService.queryUcardUserList();
    }

    /**
     * 币种配置更改
     */
    @PostMapping("/global/currencies/config")
    public BaseResultDto globalCurrenciesConfig(@RequestBody GlobalCurrenciesConfigEntity entity) throws ServiceException {
        return wasabiCardFeignService.globalCurrenciesConfig(entity);
    }

    /**
     * 查询汇率和手续费率
     */
    @PostMapping("/global/query/exchange/rate")
    public BaseResultDto queryExchangeRate(@RequestBody GlobalQueryExchangeRateEntity entity) throws ServiceException {
        return wasabiCardFeignService.queryExchangeRate(entity);
    }

    /**
     * 查询最新汇率
     */
    @PostMapping("/global/query/latest/exchange/rate")
    public BaseResultDto getExchangeRateByCurrency(@RequestBody GlobalQueryExchangeRateEntity entity) throws ServiceException {
        return wasabiCardFeignService.getExchangeRateByCurrency(entity);
    }

    /**
     * 查询支持的城市列表
     */
    @PostMapping("/global/query/bank/cities")
    public BaseResultDto queryBankCities(@RequestBody CardBankCitiesEntity entity) throws ServiceException {
        return wasabiCardFeignService.queryBankCities(entity);
    }

    /**
     * 查询币种全局配置
     */
    @PostMapping("/global/query/currencies/config")
    public BaseResultDto getCurrenciesGlobalConfig() throws ServiceException {
        return wasabiCardFeignService.getCurrenciesGlobalConfig();
    }

    /**
     * 取消交易订单
     */
    @PostMapping("/global/cancel/order")
    public BaseResultDto globalCancelOrder(@RequestBody GlobalCancelOrderEntity entity) throws Exception {
        return wasabiCardFeignService.globalCancelOrder(entity);
    }

    /**
     * 补充资料
     */
    @PostMapping("/global/supplementary/data")
    public BaseResultDto supplementaryData(@RequestBody WasabiTransactionSubmitRfiEntity entity) throws Exception {
        return wasabiCardFeignService.supplementaryData(entity);
    }

    /**
     * 查询速汇订单详情
     */
    @PostMapping("/global/order/details")
    public BaseResultDto queryGlobalOrderDetails(@RequestBody BaseEntity entity) throws ServiceException {
        return wasabiCardFeignService.queryGlobalOrderDetails(entity);
    }

    /**
     * 获取收款用户列表
     */
    @PostMapping("/global/receiver/user/list")
    BaseResultDto getGlobalReceiverUserList(@RequestBody GlobalReceiverUserEntity entity) throws ServiceException {
        return wasabiCardFeignService.getGlobalReceiverUserList(entity);
    }

    /**
     * 删除收款用户
     */
    @PostMapping("/global/receiver/user/delete")
    BaseResultDto deleteGlobalReceiverUser(@RequestBody BaseEntity entity) throws ServiceException{
        return wasabiCardFeignService.deleteGlobalReceiverUser(entity);
    }

    /**
     * 区块链配置列表
     */
    @PostMapping("/card/blockchain/config/page")
    ResultWithPagerDto<CardBlockchainConfigDto> getCardBlockchainConfigPageList(@RequestBody CardBlockchainConfigPageEntity entity) throws ServiceException{
        return wasabiCardFeignService.getCardBlockchainConfigPageList(entity);
    }

    /**
     * 区块链下拉列表
     */
    @PostMapping("/card/blockchain/dropdown")
    BaseResultDto getCardBlockchainDropdown() throws ServiceException{
        return wasabiCardFeignService.getCardBlockchainDropdown();
    }

    /**
     * 新增区块链配置
     */
    @PostMapping("/card/blockchain/config/add")
    BaseResultDto addCardBlockchainConfig(@RequestBody CardBlockchainConfigAddEntity entity) throws ServiceException{
        return wasabiCardFeignService.addCardBlockchainConfig(entity);
    }

    /**
     * 修改区块链配置
     */
    @PostMapping("/card/blockchain/config/update")
    BaseResultDto updateCardBlockchainConfig(@RequestBody CardBlockchainConfigUpdateEntity entity) throws ServiceException{
        return wasabiCardFeignService.updateCardBlockchainConfig(entity);
    }

    /**
     * 删除区块链配置
     */
    @PostMapping("/card/blockchain/config/delete")
    BaseResultDto deleteCardBlockchainConfig(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return wasabiCardFeignService.deleteCardBlockchainConfig(entity);
    }

    /**
     * 区块链汇率配置列表
     */
    @PostMapping("/card/blockchain/rate/config/page")
    ResultWithPagerDto<CardBlockchainRateConfigDto> getCardBlockchainRateConfigPageList(@RequestBody CardBlockchainRateConfigPageEntity entity) throws ServiceException{
        return wasabiCardFeignService.getCardBlockchainRateConfigPageList(entity);
    }

    /**
     * 新增区块链汇率配置
     */
    @PostMapping("/card/blockchain/rate/config/add")
    BaseResultDto addCardBlockchainRateConfig(@RequestBody CardBlockchainRateConfigAddEntity entity) throws ServiceException{
        return wasabiCardFeignService.addCardBlockchainRateConfig(entity);
    }

    /**
     * 修改区块链汇率配置
     */
    @PostMapping("/card/blockchain/rate/config/update")
    BaseResultDto updateCardBlockchainRateConfig(@RequestBody CardBlockchainRateConfigUpdateEntity entity) throws ServiceException{
        return wasabiCardFeignService.updateCardBlockchainRateConfig(entity);
    }

    /**
     * 删除区块链汇率配置
     */
    @PostMapping("/card/blockchain/rate/config/delete")
    BaseResultDto deleteCardBlockchainRateConfig(@RequestBody BaseDeleteEntities entity) throws ServiceException{
        return wasabiCardFeignService.deleteCardBlockchainRateConfig(entity);
    }

    /**
     * 钱包地址分页列表
     */
    @PostMapping("/card/deposit/address/page")
    ResultWithPagerDto<VaultodyDepositAddressDto> getDepositAddressPage(@RequestBody VaultodyDepositAddressPageEntity entity) throws ServiceException{
        return wasabiCardFeignService.getDepositAddressPage(entity);
    }

    /**
     * 重置钱包地址
     */
    @PostMapping("/card/deposit/address/reset")
    BaseResultDto resetDepositAddress(@RequestBody VaultodyResetDepositAddressEntity entity) throws ServiceException{
        return wasabiCardFeignService.resetDepositAddress(entity);
    }

    /**
     * 加密货币交易分页列表
     */
    @PostMapping("/encrypted/wallet/transaction/page")
    ResultWithPagerDto<EncryptedWalletTransactionDto> getEncryptedWalletTransactionPage(@RequestBody EncryptedWalletTransactionPageEntity entity,InfoEntity infoEntity) throws ServiceException{
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.getEncryptedWalletTransactionPage(entity);
    }

    /**
     * 卡扣款分页列表
     */
    @PostMapping("/card/withdraw/page")
    ResultWithPagerDto<CardWithdrawDto> queryCardWithdrawPage(@RequestBody CardWithdrawPageEntity entity) throws ServiceException{
        return wasabiCardFeignService.queryCardWithdrawPage(entity);
    }

    /**
     * 卡3ds分页列表
     */
    @PostMapping("/card/3ds/transaction/page")
    ResultWithPagerDto<Card3dsTransactionDto> queryCard3dsTransactionPage(@RequestBody Card3dsTransactionPageEntity entity,InfoEntity infoEntity) throws ServiceException{
        entity.setMerchantId(infoEntity.getIbInfo().getMerchantId());
        return wasabiCardFeignService.queryCard3dsTransactionPage(entity);
    }

    /**
     * 卡扣款列表导出
     */
    @PostMapping("/card/withdraw/list/export")
    public void cardWithdrawListExport(@RequestBody CardWithdrawPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<CardWithdrawDto>> resultDto = wasabiCardFeignService.cardWithdrawListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<CardWithdrawExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    CardWithdrawExportDto dto = new CardWithdrawExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setStatus(CardStatusTypeEnum.matchCode(item.getStatus()));
                    dto.setType(CardWithdrawTypeEnum.matchCode(item.getType()));
                    dto.setTransactionTime(DateUtil.formatTimestamp(item.getTransactionTime()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_WITHDRAW_LIST_EXPORT"), dtos, CardWithdrawExportDto.class, response);
        }
    }

    /**
     * 3ds列表导出
     */
    @PostMapping("/card/3ds/transaction/list/export")
    public void card3dsTransactionListExport(@RequestBody Card3dsTransactionPageEntity entity, HttpServletResponse response) throws Exception {
        BaseResultDto<List<Card3dsTransactionDto>> resultDto = wasabiCardFeignService.card3dsTransactionListExport(entity);
        if (resultDto != null && resultDto.getCode() == 200) {
            List<Card3dsTransactionExportDto> dtos = Lists.newArrayList();
            if (CollectionUtils.isNotEmpty(resultDto.getData())) {
                resultDto.getData().forEach((item) -> {
                    Card3dsTransactionExportDto dto = new Card3dsTransactionExportDto();
                    BeanUtils.copyProperties(item, dto);
                    dto.setCID(item.getCId());
                    dto.setName(NameUtil.getName(item.getCountry(), item.getLastName(), null, item.getFirstName()));
                    item.setAreaCode(item.getAreaCode() == null ? "" : item.getAreaCode());
                    item.setMobile(item.getMobile() == null ? "" : item.getMobile());
                    dto.setMobile(item.getAreaCode() + " " + item.getMobile());
                    dto.setType(Card3dsTransactionTypeEnum.matchCode(item.getType()));
                    dtos.add(dto);
                });
            }
            ExportUtil.transferToResponse(FileProcessUtil.genExportFileName("CARD_3DS_TRANSACTION_LIST_EXPORT"), dtos, Card3dsTransactionExportDto.class, response);
        }
    }
}
