package com.fs.store.service.handler;

import com.fs.common.core.domain.R;
import com.fs.store.domain.FsStoreOrder;
import com.fs.store.domain.FsUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class PaymentHandlerHolder {

    private static List<PaymentHandler> handlerList;

    @Autowired
    public void setHandlerList(List<PaymentHandler> handlerList) {
        PaymentHandlerHolder.handlerList = handlerList;
    }

    public static PaymentHandler findBest(String code){
        for (PaymentHandler paymentHandler : handlerList) {
            if(paymentHandler.support(code)){
                return paymentHandler;
            }
        }
        return null;
    }
}
