package co.yixiang.yshop.module.pay.strategy;

import co.yixiang.yshop.module.pay.strategy.type.AliPay;
import co.yixiang.yshop.module.pay.strategy.type.WeChatPay;
import co.yixiang.yshop.module.pay.strategy.type.NowMoneyPay;

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

public class PayFactory {

    private static final PayFactory factory = new PayFactory();

    private PayFactory() {
    }

    private static final Map<Object, Object> PayMap = new HashMap<>(16);

    static {
        PayMap.put(PayEnum.ALI.getCode(), new AliPay());
        PayMap.put(PayEnum.WEIXIN.getCode(), new WeChatPay());
    }

    public Pay create(String payCode) {
        return (Pay) PayMap.get(payCode);
    }

    public static PayFactory getInstance() {
        return factory;
    }
}
