package com.friday.custody.service.logicService.impl;

import com.friday.custody.context.DataDictionaryStrategyContext;
import com.friday.custody.enums.DataDictionaryTypeEnum;
import com.friday.custody.exception.RRException;
import com.friday.custody.service.basicService.impl.*;
import com.friday.custody.service.logicService.DataDictionaryBasicService;
import com.friday.custody.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service("dataDictionaryBasicService")
@Slf4j
public class DataDictionaryBasicServiceImpl implements DataDictionaryBasicService {
    @Autowired
    private DataDictionaryStrategyContext dataDictionaryStrategyContext;


    // "1" 1
    @Autowired
    private DataDictionaryFundOrganizationFormServiceImpl fundOrganizationFormService;
    // "2" 1
    @Autowired
    private DataDictionaryFundTypeServiceImpl fundTypeService;
    // "3" 1
    @Autowired
    private DataDictionaryFundOperationFormServiceImpl fundOperationFormService;
    // "4" 1
    @Autowired
    private DataDictionaryProductStatusServiceImpl productStatusService;
    // "5" 1
    @Autowired
    private DataDictionaryDurationTypeServiceImpl durationTypeService;
    // "6" 1
    @Autowired
    private DataDictionaryFieldSettlementModeServiceImpl settlementModeService;
    // "7" 1
    @Autowired
    private DataDictionaryServiceModelServiceImpl serviceModelService;
    // "" 1
    @Autowired
    private DataDictionaryTypeCustomerCsdcServiceImpl customerCsdcService;
    // ""  存在问题  需要跟客户类型关联  故 这个字典表需要单独玩
    @Autowired
    private DataDictionaryTypeCertificateCsdcServiceImpl identityCsdcService;
    // "" 1
    @Autowired
    private DataDictionaryDurationCurrencyServiceImpl currencyService;
    // "" 1
    @Autowired
    private DataDictionaryFundClassificationLogoServiceImpl fundClassificationLogoService;
    @Autowired
    private DataDictionaryDividendWayServiceImpl dividendWayService;
    @Autowired
    private DataDictionaryBusinessNameServiceImpl businessNameService;
    // "" 1
    @Autowired
    private DataDictionaryPaymentDirectionServiceImpl paymentDirectionService;

    @Autowired
    private DataDictionaryReviewStatusServiceImpl reviewStatusService;
    @Autowired
    private DataDictionarySellerServiceImpl sellerService;
    @Autowired
    private DataDictionaryConfirmStatusServiceImpl confirmStatusService;
    @Autowired
    private DataDictionaryAccountStatusServiceImpl accountStatusService;
    @Autowired
    private DataDictionaryAccrualWayServiceImpl accrualWayService;
    @Autowired
    private DataDictionaryBankCodeServiceImpl bankCodeService;
    @Autowired
    private DataDictionaryHandleTypeServiceImpl handleTypeService;
    @Autowired
    private DataDictionaryPaymentWayServiceImpl paymentWayService;
    @Autowired
    private DataDictionaryShareAdjustServiceImpl shareAdjustService;
    @Autowired
    private DataDictionaryTaLaunchFlagServiceImpl taLaunchFlagService;
    @Autowired
    private DataDictionaryTaTransactionConfirmationDaysServiceImpl taTransactionConfirmationDaysService;
    @Autowired
    private DataDictionaryPrivateFundTypeServiceImpl privateFundTypeService;
    @Autowired
    private DataDictionaryAccountTypeServiceImpl accountTypeService;
    @Autowired
    private DataDictionaryShareSourceServiceImpl shareSourceService;
    @Autowired
    private DataDictionaryTypeOfOpenDayServiceImpl typeOfOpenDayService;
    @Autowired
    private DataDictionaryMatchStatusServiceImpl matchStatusService;
    @Autowired
    private DataDictionaryReturnVisitStatusServiceImpl returnVisitStatusService;
    @Autowired
    private DataDictionaryOrderTransactionStatusServiceImpl orderTransactionStatusService;
    @Autowired
    private DataDictionaryOrderStatusServiceImpl orderStatusService;
    @Autowired
    private DataDictionaryTypesOfFeeServiceImpl typesOfFeeService;
    @Autowired
    private DataDictionarySellerStatusServiceImpl sellerStatusService;
    @Autowired
    private DataDictionaryTypeOfFundValuationServiceImpl typeOfFundValuationService;


    @Autowired
    private DataDictionaryTypeOfSellerServiceImpl typeOfSellerService;
    @Autowired
    private DataDictionaryTypeOfRefinancingModeServiceImpl dataDictionaryTypeOfRefinancingModeService;
    @Autowired
    private DataDictionaryProjectProgressServiceImpl dataDictionaryProjectProgressService;


    @Override
    public Map<String, String> queryWithDetail(DataDictionaryTypeEnum dicType, String trustNo) {
        try {
            DataDictionaryBasicService basicService;
            switch (dicType) {
                case FUND_ORGANIZATION_SERVICE:
                    basicService = fundOrganizationFormService;
                    break;
                case FUND_TYPE_SERVICE:
                    basicService = fundTypeService;
                    break;
                case FUND_OPERATION_FORM_SERVICE:
                    basicService = fundOperationFormService;
                    break;
                case PRODUCT_STATUS_SERVICE:
                    basicService = productStatusService;
                    break;
                case DURATION_TYPE_SERVICE:
                    basicService = durationTypeService;
                    break;
                case SETTLEMENT_MODE_SERVICE:
                    basicService = settlementModeService;
                    break;
                case SERVICE_MODEL_SERVICE:
                    basicService = serviceModelService;
                    break;
                case CUST_TYPE_CSDC_SERVICE:
                    basicService = customerCsdcService;
                    break;
                case IDENTITY_TYPE_CSDC_SERVICE:
                    basicService = identityCsdcService;
                    break;
                case CURRENCY_SERVICE:
                    basicService = currencyService;
                    break;
                case FUND_CLASSIFICATION_LOGO_SERVICE:
                    basicService = fundClassificationLogoService;
                    break;
                case DIVIDEND_WAY_SERVICE:
                    basicService = dividendWayService;
                    break;
                case PAYMENT_DIRECTION_SERVICE:
                    basicService = paymentDirectionService;
                    break;
                case SELLER_SERVICE:
                    basicService = sellerService;
                    break;
                case BUSINESS_NAME_SERVICE:
                    basicService = businessNameService;
                    break;
                case CONFIRM_STATUS_SERVICE:
                    basicService = confirmStatusService;
                    break;
                case REVIEW_STATUS_SERVICE:
                    basicService = reviewStatusService;
                    break;
                case ACCOUNT_STATUS_SERVICE:
                    basicService = accountStatusService;
                    break;
                case ACCRUAL_WAY_SERVICE:
                    basicService = accrualWayService;
                    break;
                case BANK_CODE_SERVICE:
                    basicService = bankCodeService;
                    break;
                case HANDLE_TYPE_SERVICE:
                    basicService = handleTypeService;
                    break;
                case PAYMENT_WAY_SERVICE:
                    basicService = paymentWayService;
                    break;
                case SHARE_ADJUST_SERVICE:
                    basicService = shareAdjustService;
                    break;
                case TA_LAUNCH_FLAG_SERVICE:
                    basicService = taLaunchFlagService;
                    break;

                case TA_TRANSACTION_CONFIRM_ATION_DAYS_SERVICE:
                    basicService = taTransactionConfirmationDaysService;
                    break;

                case PRIVATE_FUND_TYPE_SERVICE:
                    basicService = privateFundTypeService;
                    break;
                case ACCOUNT_TYPE_SERVICE:
                    basicService = accountTypeService;
                    break;
                case SHARE_SOURCE_SERVICE:
                    basicService = shareSourceService;
                    break;
                case TYPE_OF_OPEN_DAY_SERVICE:
                    basicService = typeOfOpenDayService;
                    break;
                case MATCH_STATUS_SERVICE:
                    basicService = matchStatusService;
                    break;
                case RETURN_VISIT_STATUS_SERVICE:
                    basicService = returnVisitStatusService;
                    break;
                case ORDER_TRANSACTION_STATUS_SERVICE:
                    basicService = orderTransactionStatusService;
                    break;
                case ORDER_STATUS_SERVICE:
                    basicService = orderStatusService;
                    break;
                case TYPES_OF_FEE_SERVICE:
                    basicService = typesOfFeeService;
                    break;
                case SELLER_STATUS_SERVICE:
                    basicService = sellerStatusService;
                    break;
                case TYPE_OF_SELLER_SERVICE:
                    basicService = typeOfSellerService;
                    break;
                case REFINANCING_MODE:
                    //再融资方式
                    basicService = dataDictionaryTypeOfRefinancingModeService;
                    break;
                case PROJECT_PROGRESS:
                    //项目进度
                    basicService = dataDictionaryProjectProgressService;
                    break;
                case TYPE_OF_FUND_VALUATION:
                    //估值表kmCode
                    basicService = typeOfFundValuationService;
                    break;

                default:
                    throw new RRException("该字典不存在");
            }
            return basicService.queryWithDetail(trustNo);
        } catch (Exception e) {
            log.error("数据字典查询失败：", e);
            return new HashMap<>();
        }
    }

    @Override
    public Map<String, String> queryWithDetail(String trustNo) {
        return null;
    }


    @Override
    public R queryData(String type) {
        return dataDictionaryStrategyContext.getDataDictionary(type);
    }
}
