package com.taoke.autopay.utils.order;
|
|
import com.taoke.autopay.entity.OrderChannelEnum;
|
import com.taoke.autopay.utils.HttpUtil;
|
import com.taoke.autopay.utils.StringUtil;
|
import net.sf.json.JSONObject;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
|
import java.io.UnsupportedEncodingException;
|
import java.net.URLEncoder;
|
|
/**
|
* @author hxh
|
* @title: OrderChannelApiUtil
|
* @description:
|
* @date 2024/9/14 17:07
|
*/
|
public class OrderChannelApiUtil {
|
|
private static Logger logger = LoggerFactory.getLogger("dyorderApiLogger");
|
|
/**
|
* @return boolean
|
* @author hxh
|
* @description 获取渠道商家是否可以付款
|
* @date 17:10 2024/9/14
|
* @param: channel
|
* @param: orderChannelName
|
**/
|
public static boolean isMerchantCanPay(OrderChannelEnum channel, String merchant) throws UnsupportedEncodingException {
|
if (channel == OrderChannelEnum.cyx) {
|
String url = String.format("https://api.youihuo.com/open/free.checkKsCompanyName?bsName=%s&apiKey=%s", URLEncoder.encode(merchant, "UTF-8"), OrderChannelUtil.CYX_API_KEY);
|
String result = HttpUtil.get(url);
|
logger.info(String.format("超佣享商家付款判断:%s-%s", merchant, result));
|
JSONObject root = JSONObject.fromObject(result);
|
System.out.println(result);
|
if(root.optInt("code") == 1000){
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public static void main(String[] args) throws UnsupportedEncodingException {
|
|
System.out.print( isMerchantCanPay(OrderChannelEnum.cyx,"广州市天河区长兴街安尔雅服饰商行1"));
|
}
|
|
|
}
|