package com.chinacreator.process.util;

import com.chinacreator.common.support.util.SpringContextUtil;
import com.chinacreator.common.util.URLUtil;
import com.chinacreator.process.dao.DictionaryDao;

public class CapUtil {
	/*
		String usermob = orderInfo.getUsermob();		//手机号码
		String vacid = orderInfo.getVacid();			//产品ID
		String spcode = orderInfo.getSpcode(); 			//P代码
		String ordertype = orderInfo.getOrdertype();		//操作类型，0订购，1退订
		String servicetype = orderInfo.getServicetype();  	//服务编码
		String sequence = orderInfo.getSequence();		//统一认证序列
		String fee = orderInfo.getFee();				//资费
		String token = orderInfo.getToken();
		String accesstype = orderInfo.getAccesstype();  sp/cp的二次认证方式: 	1：H5认证 2：SDK认证 3：短信认证  4：页面认证
	 */


	/**
	 * 调cap接口
	 * @param cpid
	 * @param spid
	 * @param userId
	 * @param spCode
	 * @param productId
	 * @param type
	 * @param sequence
	 * @param accesstype
	 * @param fee
	 * @param token
	 * @return
	 * @throws Exception
	 */
	public static String cap(String cpid, String spid, String userId,String spCode, String productId,String type, String sequence, String accesstype, String fee, String token) throws Exception{
		DictionaryDao dictionaryDao = SpringContextUtil.getBean(DictionaryDao.class);
		String capUrl = dictionaryDao.getValue("capUrl");
		if(capUrl.indexOf("?") == -1) {
			capUrl += "?";
		} else {
			capUrl += "&";
		}
		capUrl += "usermob=" + userId;
		capUrl += "&vacid=" + productId;
		capUrl += "&spcode=" + spCode;
		capUrl += "&ordertype=" + type;
		capUrl += "&servicetype=80";;
		capUrl += "&sequence=" + sequence;
		capUrl += "&fee=" + fee;
		capUrl += "&token=" + token;
		capUrl += "&accesstype=" + accesstype;
		capUrl += "&cpid=" + cpid;
		capUrl += "&spid=" + spid;
		String resultStr = URLUtil.get(capUrl);
		return resultStr;
	}


	public static String capQuery(String userId) throws Exception {
		DictionaryDao dictionaryDao = SpringContextUtil.getBean(DictionaryDao.class);
		String capUrl = dictionaryDao.getValue("capQueryUrl");
		capUrl += "?usermob=" + userId;
		String resultStr = URLUtil.get(capUrl);
		return resultStr;
	}

	public static String kbxkQuery(String userId) throws Exception {
		DictionaryDao dictionaryDao = SpringContextUtil.getBean(DictionaryDao.class);
		String capUrl = dictionaryDao.getValue("kbxkQueryUrl");
		capUrl += "?usermob=" + userId;
		String resultStr = URLUtil.get(capUrl);
		return resultStr;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {

	}
}
