package com.neusoft.smart.pos.exchangeStrategy.persistent.repository;

import com.neusoft.smart.pos.exchangeStrategy.constants.ExchangeStrategyErrorCode;
import com.neusoft.smart.pos.framework.exception.BusinessCommonException;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 倍数转换策略
 * 返回值 = 输入值 * 倍数
 */
@Component("MultipleExchangeStrategy")
public class MultipleExchangeStrategy implements IExchangeStrategy {
    @Override
    public Long doExchange(Long amount, String params) {
        String[] paramList = params.split(";");
        if(paramList.length > 0) {
            Long multiple = new Long(paramList[0]);
            return amount*multiple;
        } else {
            throw new BusinessCommonException(ExchangeStrategyErrorCode.EXCHANGE_STRATEGY_PARAMS_EMPTY_ERROR);
        }
    }
}
