package com.crm.ucard.controller;

import com.crm.rely.backend.core.constant.FeignClientAnnotation;
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.custom.kyc.WebsdkLinkAliEntity;
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.exception.ServiceException;
import com.crm.rely.backend.util.GetIpAndMac;
import com.crm.ucard.service.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

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

    @Autowired
    private UcardService ucardService;
    @Autowired
    private WasabiCardService wasabiCardService;
    @Autowired
    private VaultodyService vaultodyService;

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

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

    /**
     * 更新卡片类型和基本信息
     */
    @PostMapping("/card/types")
    @FeignClientAnnotation
    public BaseResultDto getCardTypes() throws ServiceException {
        wasabiCardService.saveCardTypeList();
        wasabiCardService.cardUpdateCountry();
        wasabiCardService.updateOccupationList();
        return BaseResultDto.success();
    }

    /**
     * 商户用户分页列表
     */
    @PostMapping("/merchant/user/page")
    @FeignClientAnnotation
    public ResultWithPagerDto<MerchantUserDto> getMerchantUserPageList(@RequestBody MerchantUserPageEntity entity) throws ServiceException {
        return ucardService.getMerchantUserPageList(entity);
    }

    /**
     * 商户用户注册
     */
    @PostMapping("/merchant/user/register")
    @FeignClientAnnotation
    public BaseResultDto managerRegisterMerchantUser(@RequestBody @Validated CardMerchantUserEntity request, HttpServletRequest servletRequest) throws ServiceException {
        String ip = GetIpAndMac.getIp(servletRequest);
        request.setIpAddress(ip);
        return wasabiCardService.registerMerchantUser(request);
    }

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

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

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

    /**
     * 获取kyc认证分页列表
     */
    @PostMapping("/merchant/kyc/page")
    @FeignClientAnnotation
    ResultWithPagerDto<CardKycStatusDto> getKycPageList(@RequestBody CardKycStatusPageEntity entity) throws ServiceException {
        return ucardService.getKycPageList(entity);
    }

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

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

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

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

    /**
     * 获取卡片申请列表
     */
    @PostMapping("/card/apply/page")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardApplyDto> getCardApplyPageList(@RequestBody CardApplyPageEntity entity) throws ServiceException {
        return ucardService.getCardApplyPageList(entity);
    }

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

    /**
     * 获取卡片列表
     */
    @PostMapping("/card/page")
    @FeignClientAnnotation
    public ResultWithPagerDto<UcardCardDto> getCardPageList(@RequestBody CardPageEntity entity) throws ServiceException {
        return ucardService.getCardPageList(entity);
    }

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

    /**
     * 银行卡充值
     */
    @PostMapping("/card/recharge")
    @FeignClientAnnotation
    public BaseResultDto rechargeCard(@RequestBody WasabiBalanceEntity request) throws ServiceException {
        return wasabiCardService.cardDeposit(request);
    }

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

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

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

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

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

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

    /**
     * 查询充值记录
     */
    @PostMapping("/card/recharge/records")
    @FeignClientAnnotation
    public BaseResultDto<List<WasabiTransactionDto>> queryRechargeRecords(@RequestBody WasabiTransactionEntity entity) throws Exception {
        entity.setType("deposit");
        return BaseResultDto.success(wasabiCardService.getCardTransactionList(entity));
    }

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

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

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

    /**
     * 找回密码
     */
    @PostMapping("/card/password/reset")
    @FeignClientAnnotation
    public BaseResultDto<WasabiUpdatePinDto> resetPassword(@RequestBody WasabiUpdatePinEntity entity) throws ServiceException {
        return wasabiCardService.updatePin(entity);
    }

    /**
     * 查询交易记录分页列表
     */
    @PostMapping("/card/transac/page")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardTransacOrderDto> getTransactionPageList(@RequestBody CardTransacOrderPageEntity request) throws ServiceException {
        return ucardService.getTransacOrderPageList(request);
    }

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

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

    /**
     * 校验文件
     */
    @PostMapping("/validated/file")
    @FeignClientAnnotation
    public void validatedFile(@RequestParam(value = "file") MultipartFile file) throws ServiceException {
        wasabiCardService.validatedFile(file);
    }

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

    /**
     * 查询职业信息
     */
    @PostMapping("/card/occupation/list")
    @FeignClientAnnotation
    public BaseResultDto<List<WasabiOccupationsDto>> getOccupationList() throws ServiceException {
        return wasabiCardService.getOccupationList();
    }

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

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

    /**
     * 卡权限分页列表
     */
    @PostMapping("/card/permission/page")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardPermissionDto> queryPermissionPageList(@RequestBody CardPermissionPageEntity entity) throws ServiceException {
        return wasabiCardService.queryPermissionPageList(entity);
    }

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

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

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

    /**
     * 操作记录分页列表
     */
    @PostMapping("/card/operate/page")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardOperateDto> queryOperatePageList(@RequestBody CardOperatePageEntity entity) throws ServiceException {
        return wasabiCardService.queryOperatePageList(entity);
    }

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

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

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

    /**
     * 身份认证获取web链接
     *
     * @param entity
     * @return
     */
    @PostMapping("/getWebsdkLink")
    public BaseResultDto getWebsdkLink(@RequestBody WebsdkLinkAliEntity entity, InfoEntity infoEntity) throws Exception {
        return wasabiCardService.getWebsdkLink(entity, infoEntity.getCustomInfo().getId());
    }

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

    /**
     * 证件类型配置列表
     *
     * @param entity
     * @return
     */
    @PostMapping("/card/id/type/config/list")
    @FeignClientAnnotation
    public ResultWithPagerDto<CardIdTypeConfigDto> getCardIdTypeConfigList(@RequestBody CardIdTypeConfigPageEntity entity) throws ServiceException {
        return wasabiCardService.getCardIdTypeConfigList(entity);
    }

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

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

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

    /**
     * 查询cvv码
     */
    @PostMapping("/card/query/cvv")
    @FeignClientAnnotation
    public BaseResultDto cardQueryCvv(@RequestBody CardVerifyGoogleCodeEntity entity) throws ServiceException {
        return wasabiCardService.cardQueryCvv(entity);
    }

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

    /**
     * 导入卡号
     */
    @PostMapping("/card/number/import")
    @FeignClientAnnotation
    BaseResultDto cardNumberImport(@RequestBody List<CardNumberAddEntity> entityList) throws ServiceException {
        return wasabiCardService.cardNumberImport(entityList);
    }

    /**
     * 卡号列表
     */
    @PostMapping("/card/number/list")
    @FeignClientAnnotation
    ResultWithPagerDto<CardNumberDto> queryCardNumberList(@RequestBody CardNumberPageEntity entity) throws ServiceException {
        return wasabiCardService.queryCardNumberList(entity);
    }

    /**
     * 卡号列表
     */
    @PostMapping("/card/number/dropdown")
    @FeignClientAnnotation
    BaseResultDto queryCardNumberDropdown(@RequestBody CardNumberPageEntity entity) throws ServiceException {
        return wasabiCardService.queryCardNumberDropdown(entity);
    }

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

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

    /**
     * 用户信息导出
     */
    @PostMapping("/merchant/user/list/export")
    @FeignClientAnnotation
    public BaseResultDto<List<MerchantUserDto>> merchantUserListExport(@RequestBody MerchantUserPageEntity entity) throws ServiceException {
        return wasabiCardService.merchantUserListExport(entity);
    }

    /**
     * kyc认证列表导出
     */
    @PostMapping("/merchant/kyc/list/export")
    @FeignClientAnnotation
    BaseResultDto<List<CardKycStatusDto>> merchantKycListExport(@RequestBody CardKycStatusPageEntity entity) throws ServiceException {
        return wasabiCardService.merchantKycListExport(entity);
    }

    /**
     * 卡片申请列表导出
     */
    @PostMapping("/card/apply/list/export")
    @FeignClientAnnotation
    public BaseResultDto<List<CardApplyDto>> cardApplyListExport(@RequestBody CardApplyPageEntity entity) throws ServiceException {
        return wasabiCardService.cardApplyListExport(entity);
    }

    /**
     * 卡片列表导出
     */
    @PostMapping("/card/list/export")
    @FeignClientAnnotation
    public BaseResultDto<List<UcardCardDto>> cardListExport(@RequestBody CardPageEntity entity) throws ServiceException {
        return wasabiCardService.cardListExport(entity);
    }

    /**
     * 交易记录列表导出
     */
    @PostMapping("/card/transac/record/export")
    @FeignClientAnnotation
    public BaseResultDto<List<CardTransacOrderDto>> cardTransacRecordExport(@RequestBody CardTransacOrderPageEntity request) throws ServiceException {
        return wasabiCardService.cardTransacRecordExport(request);
    }

    /**
     * 钱包余额记录列表导出
     */
    @PostMapping("/card/wallet/record/export")
    @FeignClientAnnotation
    public BaseResultDto<List<CardWalletRecordDto>> cardWalletRecordExport(@RequestBody CardWalletRecordPageEntity request) throws ServiceException {
        return wasabiCardService.cardWalletRecordExport(request);
    }

    /**
     * 操作记录列表导出
     */
    @PostMapping("/card/operate/record/export")
    @FeignClientAnnotation
    public BaseResultDto<List<CardOperateDto>> cardOperateRecordExport(@RequestBody CardOperatePageEntity entity) throws ServiceException {
        return wasabiCardService.cardOperateRecordExport(entity);
    }

    /**
     * 充值记录导出
     */
    @PostMapping("/card/recharge/list/export")
    @FeignClientAnnotation
    public BaseResultDto<List<CardRechargeOrderDto>> cardRechargeListExport(@RequestBody CardRechargePageEntity entity) throws ServiceException {
        return wasabiCardService.cardRechargeListExport(entity);
    }

    /**
     * 速汇订单导出
     */
    @PostMapping("/global/order/list/export")
    @FeignClientAnnotation
    public BaseResultDto<List<GlobalOrderDto>> globalOrderListExport(@RequestBody GlobalOrderPageEntity entity) throws ServiceException {
        return wasabiCardService.globalOrderListExport(entity);
    }

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

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

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

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

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

    /**
     * 币种分页列表
     */
    @PostMapping("/global/currencies/list")
    @FeignClientAnnotation
    ResultWithPagerDto<WasabiAvailableCurrenciesListDto> getCurrenciesPageList(@RequestBody GlobalCurrenciesPageListEntity entity) throws ServiceException {
        return wasabiCardService.getCurrenciesPageList(entity);
    }

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

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

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

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

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

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

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

    /**
     * 查询最新汇率
     */
    @PostMapping("/global/query/latest/exchange/rate")
    @FeignClientAnnotation
    public BaseResultDto getExchangeRateByCurrency(@RequestBody GlobalQueryExchangeRateEntity entity) throws ServiceException {
        return BaseResultDto.success(wasabiCardService.getExchangeRateByCurrency(entity.getPayoutCurrency(), entity.getTransferTypeId(), entity.getPayoutMethodId()));
    }

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

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

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

    /**
     * 速汇订单分页列表
     */
    @PostMapping("/global/order/page/list")
    @FeignClientAnnotation
    public ResultWithPagerDto<GlobalOrderDto> globalOrderPageList(@RequestBody GlobalOrderPageEntity entity) throws Exception {
        return wasabiCardService.globalOrderPageList(entity);
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    /**
     * 加密货币交易记录导出
     */
    @PostMapping("/encrypted/wallet/transaction/list/export")
    @FeignClientAnnotation
    BaseResultDto<List<EncryptedWalletTransactionDto>> encryptedWalletTransactionListExport(@RequestBody EncryptedWalletTransactionPageEntity entity) throws ServiceException{
        return wasabiCardService.encryptedWalletTransactionListExport(entity);
    }

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

    /**
     * 卡扣款列表导出
     */
    @PostMapping("/card/withdraw/list/export")
    @FeignClientAnnotation
    BaseResultDto<List<CardWithdrawDto>> cardWithdrawListExport(@RequestBody CardWithdrawPageEntity entity) throws ServiceException{
        return wasabiCardService.cardWithdrawListExport(entity);
    }

    /**
     * 卡3ds分页列表
     */
    @PostMapping("/card/3ds/transaction/page")
    @FeignClientAnnotation
    ResultWithPagerDto<Card3dsTransactionDto> queryCard3dsTransactionPage(@RequestBody Card3dsTransactionPageEntity entity) throws ServiceException{
        return wasabiCardService.queryCard3dsTransactionPage(entity);
    }

    /**
     * 3ds列表导出
     */
    @PostMapping("/card/3ds/transaction/list/export")
    @FeignClientAnnotation
    BaseResultDto<List<Card3dsTransactionDto>> card3dsTransactionListExport(@RequestBody Card3dsTransactionPageEntity entity) throws ServiceException{
        return wasabiCardService.card3dsTransactionListExport(entity);
    }


    /**
     * 银行卡授权交易信息数据定时同步查询
     */
    @Scheduled(cron = "0 0 1 * * ?")
    public void queryOrderInfo() throws ServiceException {

        log.info("银行卡授权交易信息数据定时同步查询开始: .............................");
        try {
            wasabiCardService.queryOrderInfo();
        } catch (Exception e) {
            log.error("银行卡授权交易信息数据定时同步任务执行失败", e);
        }
        log.info("银行卡授权交易信息数据定时同步查询结束: .............................");
    }

    /**
     * 激活处理中数据查询卡信息并更新数据库
     */
    @Scheduled(cron = "0 0 * * * ?")
    public void queryCardInfo() throws Exception {

        log.info("激活中数据同步定时任务开始: .............................");
        try {
            wasabiCardService.queryCardInfo();
        } catch (Exception e) {
            log.error("激活中数据同步定时任务执行失败", e);
        }
        log.info("激活中数据同步定时任务结束: .............................");
    }

    /**
     * 待激活卡片更新邮寄状态任务
     */
    @Scheduled(cron = "0 0 * * * ?")
    public void queryCardLogisticsStatus() throws Exception {

        log.info("待激活卡片更新邮寄状态任务开始: .............................");
        try {
            wasabiCardService.queryCardLogisticsStatus();
        } catch (Exception e) {
            log.error("待激活卡片更新邮寄状态任务执行失败", e);
        }
        log.info("待激活卡片更新邮寄状态任务结束: .............................");
    }

}
