package cn.pluss.platform.vo;

import cn.pluss.platform.entity.MerchantRateNew;
import cn.pluss.platform.entity.MerchantRateNewRecord;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * <p>
 * 商户费率表(新)
 * </p>
 *
 * @author Djh
 * @since 2021-08-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class MerchantRateNewRecordVO extends MerchantRateNewRecord {

    private String userId;

    /**
     * 通道类型
     */
    private String channelType;

    /**
     * 微信费率等级，费率参考字典表wx_rate
     */
    private BigDecimal wxRateValue;


    /**
     * 支付宝费率等级，费率参考字典表ali_rate
     */
    private BigDecimal aliRateValue;


    /**
     * 银联费率等级，费率参考字典表bank_rate
     */
    private BigDecimal bankRateValue;


    /**
     * 银联1000+费率等级，费率参考字典表bank_rate_1000+, 目前随行付不支持1000+的支付
     */
    private BigDecimal bankRateLargeValue;

    public static void setRateValue(MerchantRateNewRecordVO entity) {
        entity.setWxRateValue(BigDecimal.valueOf(entity.getWxRate()).setScale(3, RoundingMode.HALF_UP));
        entity.setAliRateValue(BigDecimal.valueOf(entity.getAliRate()).setScale(3, RoundingMode.HALF_UP));
        entity.setBankRateValue(BigDecimal.valueOf(entity.getBankRate() + 2).setScale(3, RoundingMode.HALF_UP));
        entity.setBankRateLargeValue(BigDecimal.valueOf((entity.getBankRateLarge() - 21) / 2f + 53).setScale(3, RoundingMode.HALF_UP));
    }
}