package com.jsowell.common;

import com.jsowell.common.enums.adapay.AdapayPayChannelEnum;
import com.jsowell.common.util.StringUtils;

import javax.servlet.http.HttpServletRequest;

public class UserAgentUtils {

    /**
     * 判断请求来自哪里
     */
    public static String determineRequestSource(HttpServletRequest request) {
        String userAgent = request.getHeader("user-agent");
        if (StringUtils.isBlank(userAgent)) {
            return null;
        }
        if (userAgent.contains("AlipayClient")) {
            return AdapayPayChannelEnum.ALIPAY_LITE.getValue();
        }else if (userAgent.contains("MicroMessenger")) {
            return AdapayPayChannelEnum.WX_LITE.getValue();
        }else{
            return null;
        }
    }
}
