admin
2024-09-27 17caebabf7a6a529b7039c71e21e5a324e31ea20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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"));
    }
 
 
}