package com.nokia.domainb.capability;

import cn.chinaunicom.open.common.Const;
import cn.chinaunicom.open.nlgxptconnection.COMPConnection;
import cn.chinaunicom.open.nlgxptconnection.COMPConnectionContext;
import cn.chinaunicom.open.nlgxptconnection.impl.COMPJsonConnection;

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

/**
 * 用户资料三户返回 json_microservice_users_spthreepartcheck
 */
public class SpThreePartCheck extends AbstractQuery {
    private static final String url = "http://192.168.70.130:8000/api/microservice/users/spthreepartcheck/v1";
    private static final String urlTest = "http://10.124.150.230:8000/api/microservice/users/spthreepartcheck/v1";

    public COMPConnectionContext query(String phoneNumber, String provinceCode, boolean test) {
        String realAppSecret = test ? appSecretTest : appSecret;
        String realUrl = test ? urlTest : url;
        COMPConnection compConnection = new COMPJsonConnection(appId, realAppSecret);

        // REQ
        Map<String, Object> req = new HashMap<>();
        Map<String, Object> spThreepartCheckReq = new HashMap<>();
        req.put("SP_THREEPART_CHECK_REQ", spThreepartCheckReq);
        Map<String, Object> msg = new HashMap<>();
        spThreepartCheckReq.put("MSG", msg);
        msg.put("serialNumber", phoneNumber);
        msg.put("province", provinceCode);
        msg.put("city", "720");
        // 区县码不确定
        msg.put("district", "720");
        msg.put("channelType", "18zzzzz");
        msg.put("infoList", "CUST|USER|ACCT");
        msg.put("operatorId", "v-wangyl5740-1");
        msg.put("channelId", "18zzzzz");
        msg.put("tradeTypeCode", "9999");
        msg.put("serviceClassCode", "50");
        spThreepartCheckReq.put("APPKEY", "hbltywts");
        spThreepartCheckReq.put("APPTX", appId);
        COMPConnectionContext context = compConnection.excute(Const.HttpMethodType.POST, realUrl, req, false);
        return context;
    }
}
