package com.jeequan.jeepay.thirdparty.channel.yspay;

import com.jeequan.jeepay.core.constants.CS;
import com.jeequan.jeepay.core.entity.MchApplyment;
import com.jeequan.jeepay.core.model.applyment.PaywayFee;
import com.jeequan.jeepay.core.model.applyment.YspayApplymentInfo;
import com.jeequan.jeepay.thirdparty.channel.AbsIsvmchWrapper;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Map;

@Service("yspayIsvmchWrapper")
public class YspayIsvmchWrapper extends AbsIsvmchWrapper<YspayApplymentInfo> {

    /**
     * 主要用于添加默认的D1, D0手续费
     * @param mchApplyment 商户信息
     */
    @Override
    public Map<String, PaywayFee> channelInit(Map<String, PaywayFee> mchRateConfigMap, MchApplyment mchApplyment) {

        // 配置默认D1手续费
        if (mchRateConfigMap.get("D1") == null) {
            PaywayFee paywayFee = new PaywayFee();
            paywayFee.setWayCode("D1");
            paywayFee.setFeeRate(BigDecimal.valueOf(0.0001));
            paywayFee.setFeeType(PaywayFee.FEE_TYPE_SINGLE);
            paywayFee.setApplymentSupport(CS.YES);
            mchRateConfigMap.put("D1", paywayFee);
        }

        // 配置默认D0手续费
        if (mchRateConfigMap.get("D0") == null) {
            PaywayFee paywayFee = new PaywayFee();
            paywayFee.setWayCode("D0");
            paywayFee.setFeeRate(BigDecimal.valueOf(0.001));
            paywayFee.setFeeType(PaywayFee.FEE_TYPE_SINGLE);
            paywayFee.setApplymentSupport(CS.YES);
            mchRateConfigMap.put("D1", paywayFee);
        }

        return mchRateConfigMap;
    }
}
