package cn.pluss.platform.channel;

import cn.pluss.platform.entity.MerchantRate;
import org.springframework.transaction.annotation.Transactional;

public interface MchChannelRateService {

    /**
     * 修改商户的费率
     */
    MerchantRate before(String userId, Integer rate);

    /**
     * 渠道操作
     * @param userId
     * @param rate
     */
    void process(String userId, Integer rate, MerchantRate merchantRate);

    void after(String userId, Integer rate, MerchantRate merchantRate);

    @Transactional(rollbackFor = Exception.class)
    default void changeRate(String userId, Integer rate) {
        MerchantRate merchantRate = before(userId, rate);
        process(userId, rate, merchantRate);
        after(userId, rate, merchantRate);
    }
}
