com.yeahka.android.lepos.Device.java Source code

Java tutorial

Introduction

Here is the source code for com.yeahka.android.lepos.Device.java

Source

package com.yeahka.android.lepos;

import android.app.Application;
import android.preference.PreferenceManager;
import android.text.TextUtils;

import com.google.gson.Gson;
import com.yeahka.android.lepos.device.YeahkaDevice;
import com.yeahka.mach.android.openpos.MyActivity;
import com.yeahka.mach.android.openpos.MyApplication;
import com.yeahka.mach.android.openpos.bean.BaseOADBean;
import com.yeahka.mach.android.openpos.bean.CheckLicenceBean;
import com.yeahka.mach.android.openpos.bean.OACMDBankBranch;
import com.yeahka.mach.android.openpos.bean.OACMDBankInfo;
import com.yeahka.mach.android.openpos.bean.OACMDBaseBean;
import com.yeahka.mach.android.openpos.bean.OACMDMerchantBaseInfo;
import com.yeahka.mach.android.openpos.bean.OACMDProvinceCity;
import com.yeahka.mach.android.openpos.bean.OACMDTypeInfo;
import com.yeahka.mach.android.openpos.bean.OACMDo2oUploadPictureBean;
import com.yeahka.mach.android.openpos.bean.OADBranchBank;
import com.yeahka.mach.android.openpos.bean.OADMerchantBaseInfo;
import com.yeahka.mach.android.openpos.bean.OADRequestRegister;
import com.yeahka.mach.android.openpos.bean.OADRequestVerifyCode;
import com.yeahka.mach.android.openpos.bean.OADRetrievePassword;
import com.yeahka.mach.android.openpos.bean.OADUploadPictureInfo;
import com.yeahka.mach.android.openpos.bean.OADUserBean;
import com.yeahka.mach.android.openpos.bean.OADVerifyRegister;
import com.yeahka.mach.android.openpos.bean.OADo2oUploadPhotoInfo;
import com.yeahka.mach.android.openpos.bean.ResponseCheckLicenseBean;
import com.yeahka.mach.android.openpos.bean.TLVBase;
import com.yeahka.mach.android.openpos.bean.TLVBytes;
import com.yeahka.mach.android.openpos.bean.TLVEncryptBody;
import com.yeahka.mach.android.openpos.bean.TLVHead;
import com.yeahka.mach.android.openpos.bean.TLVJson;
import com.yeahka.mach.android.openpos.mach.MachInfoWebViewActivity;
import com.yeahka.mach.android.openpos.wxapi.Constants;
import com.yeahka.mach.android.util.ByteArrayReader;
import com.yeahka.mach.android.util.HttpService.MyHttps;
import com.yeahka.mach.android.util.MyLog;
import com.yeahka.mach.android.util.ResultModel;
import com.yeahka.mach.android.util.ServerSocketConnectUtil;
import com.yeahka.mach.android.util.Util;

import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnRouteParams;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.XML;

import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.Socket;
import java.net.SocketException;
import java.net.URL;
import java.net.URLEncoder;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class Device {

    public static int DEVICE_VERSION = 316013;

    public static final int APP_NETWORK_ENVIRONMENT_FLAG = 1; /*1:? 2:? 3: 4:? URL?*/

    public static final String DEVICE_VERSION_SHOW_TEXT = Util
            .getAppVersionShowText();/*modify by lucien ?? DEVICE_VERSION  ?? APP_NETWORK_ENVIRONMENT_FLAG ??*/

    public static final String TAG = "LEPOS";

    // 2015-07-31
    // APP
    // terence update   ?1 ?
    public static final boolean APP_DEBUG_ENVIRONMENT_FLAG = APP_NETWORK_ENVIRONMENT_FLAG != 1;

    //  2015-07-31
    //  APP?
    //  true??
    //  false??
    static {
        if (APP_DEBUG_ENVIRONMENT_FLAG) {
            DEVICE_VERSION = 307008;//?
        }
    }

    public final static String PLATFORM_TAG = "DEFAULT"; // default --
    // 
    public final static int TRANSACTION_NET_FAIL = -999;
    public static final int DEVICE_NOT_BIND_ERROR = -2007;
    public final static int SYSTEM_FAIL = -998;
    public final static int TRANSACTION_OK = 0;
    public final static int APP_SHOULD_UPDATE_ERROR = -2;
    public final static int APP_MUST_UPDATE_ERROR = -1;
    public final static int LESHUA_VERSION_150 = 150;
    public final static int LESHUA_VERSION_201 = 230;
    public final static int LESHUA_VERSION_LEPOS = 220;
    public static final float DEFAULT_LEPOS_VOLUME = 0.8f;
    public static final String PIN_BACK = "FFFFFFFFFFFFFFFF";
    private int device;

    public int getDevice() {
        return device;
    }

    private int shareAppData;
    public int callType;
    public int callFor;
    public int callScreenShowType;
    public int thirdCallPayType;
    public String simSerialNumber;
    public boolean isWifiEnabled;
    public final int APP_TYPE = APP_TYPE_ANDRIOD_LEPOS;
    public String error_code, error_tip, error_msg;
    public boolean isQBStore;
    public int nSelectedGameIndex = 0;
    public String queryFangTeGameResult;
    public List<Map<String, String>> gamesList;
    // public InputFangTeGameStoreInfoActivity inputFangTeGameStoreInfo;
    public long gameProductXmlVersionTime;
    public int gameProductXmlVersion;
    // public InputQBStoreInfoActivity inputQbStoreInfo;
    private com.yeahka.android.leshua.Device leshuaDevice = null;
    private String strLocalDeviceId;

    // private Socket registerServerSocket;
    // private boolean bNeedRecycleRegisterServerSocket = false;

    public static native int nativeFunction00000();

    public static native void nativeFunction00001(int nShareAppData);

    public static native int nativeFunction0(int nShareAppData);

    public static native void nativeFunction1(int nDevice);

    public static native byte[] nativeFunction2(int nDevice);

    //    public static native byte[] nativeFunction3(int nDevice, String strSimSerialNumber, int nVersion);
    public static native byte[] nativeFunction3(int nDevice, String strSimSerialNumber, int nVersion,
            String strUserName);

    public static native void nativeFunction4(int nDevice, int nFactor1, int nFactor2, int nFactor3);

    public static native void nativeFunction5(int nDevice, String strPackagePath);

    public static native void nativeFunction6(int nDevice, int nTransferAmount);

    public static native void nativeFunction7(int nDevice, int nTransferDeepAmount);

    public static native void nativeFunction8(int nDevice, int nAmount);

    public static native int nativeFunction9(int nDevice);

    public static native void nativeFunction10(int nDevice, String strAmountString);

    public static native String nativeFunction11(int nDevice);

    public static native void nativeFunction12(int nDevice, int nPayAmount);

    public static native int nativeFunction13(int nDevice);

    public static native void nativeFunction14(int nDevice, String strPayAmountString);

    public static native String nativeFunction15(int nDevice);

    public static native void nativeFunction32(int nDevice, int nAppType);

    public static native void nativeFunction38(int nDevice, String strStoreApplicationID);

    public static native String nativeFunction39(int nDevice);

    public static native void nativeFunction40(int nDevice, String strStoreApplicationUserID);

    public static native String nativeFunction41(int nDevice);

    public static native void nativeFunction42(int nDevice, String strStoreApplicationUserName);

    public static native String nativeFunction43(int nDevice);

    public static native void nativeFunction46(int nDevice, String strUserName);

    public static native void nativeFunction52(int nDevice, String strGoodsName);

    public static native String nativeFunction53(int nDevice);

    public static native void nativeFunction54(int nDevice, String strGoodsDetail);

    public static native String nativeFunction55(int nDevice);

    public static native void nativeFunction56(int nDevice, String strGoodsProvider);

    public static native String nativeFunction57(int nDevice);

    public static native byte[] nativeFunction59(int nDevice, byte[] data1, byte[] data2);

    public static native byte[] nativeFunction60(int nDevice, byte[] data1, byte[] data2, byte[] data3);

    public static native byte[] nativeFunction61(int nDevice, byte[] data1, byte[] data2, byte[] data3,
            byte[] data4);

    public static native int nativeFunction66(int nDevice);

    public static native byte[] nativeFunction67(int nDevice);

    public static native byte[] nativeFunction68(int nDevice, String strSimSerialNumber, String strMachine,
            Object context);

    public static native byte[] nativeFunction71(int nDevice);

    public static native byte[] nativeFunction72(int nDevice);

    public static native byte[] nativeFunction82(int nDevice);

    public static native byte[] nativeFunction83(int nDevice);

    public static native byte[] nativeFunction84(int nDevice);

    public static native byte[] nativeFunction85(int nDevice);

    public static native int nativeFunction103(int nDevice, byte[] data);

    public static native byte[] nativeFunction127(int nDevice);

    public static native byte[] nativeFunction128(int nDevice, String strCrashReport);

    public static native byte[] nativeFunction190(int device);

    public static native byte[] nativeFunction191(int device, String strVolume, String strBit0To1Ratio);

    public static native byte[] nativeFunction1000(int device);

    public static native byte[] nativeFunction1001(int device, String strUsername, String strPassword);

    public static native void nativeFunction105(int nDevice, String userName);

    public static native void nativeFunction106(int nDevice, String sessionID);

    public static native void nativeFunction107(int nDevice, String merchantID);

    public static native byte[] nativeFunction1002(int nDevice);

    public static native byte[] nativeFunction1003(int nDevice);

    public static native byte[] nativeFunction1004(int nDevice);

    public static native byte[] nativeFunction1005(int nDevice, String oldPasswordMD5, String newPasswordMD5);

    public static native byte[] nativeFunction1006(int nDevice);

    public static native byte[] nativeFunction1007(int nDevice, String strTerminalId, String track2Data,
            String pin);

    public static native byte[] nativeFunction1008(int nDevice);

    //-----------terence add --2016-03-17 t+0 ---------

    //-----------terence add --2016-05-13 t+0  nMarketType---------
    public static native byte[] nativeFunction1009(int nDevice, String payOrderID, int nAmout, String strTerminalId,
            String track2Data, String pin, String longitude, String latitude, int t0Flag, int nMarketType);

    public static native byte[] nativeFunction1010(int nDevice);

    public static native byte[] nativeFunction1011(int nDevice, String payOrderID, String pinpadID,
            String track2Data, String adminPassword, String longitude, String latitude);

    public static native byte[] nativeFunction1012(int nDevice);

    //-----------terence add 2016-07-14 t0
    public static native byte[] nativeFunction1013(int nDevice, String strPayOrderID, String strLongitude,
            String strLatitude, int t0Flag);

    public static native byte[] nativeFunction1014(int nDevice);

    public static native byte[] nativeFunction1015(int nDevice, String strPayOrderID, String strLongitude,
            String strLatitude);

    public static native byte[] nativeFunction1016(int nDevice);

    public static native byte[] nativeFunction1017(int nDevice, String strPayOrderID, String strLongitude,
            String strLatitude);

    /*??TDcode*/
    public static native byte[] nativeFunction1017(int nDevice, String strPayOrderID, String strLongitude,
            String strLatitude, int t0Flag);

    public static native byte[] nativeFunction1018(int nDevice);

    public static native byte[] nativeFunction1019(int nDevice, String strPayOrderID, String strLongitude,
            String strLatitude);

    public static native byte[] nativeFunction1020(int nDevice);

    //-----------terence add --2016-03-17 t+0 --------- 1  t+0,0 ?
    //-----------terence add --2016-05-13 t+0  nMarketType---------
    public static native byte[] nativeFunction1021(int nDevice, String payOrderID, int nAmout, String strTerminalId,
            String track2Data, String pin, String longitude, String latitude, int nT0Flag, int nMarketType);

    public static native byte[] nativeFunction1022(int nDevice, String strTerminalId, String track2Data, String pin,
            String strCardSerialNo, String strICCardInfo);

    //-----------terence add --2016-03-17 t+0 ---------

    //-----------terence add --2016-05-13 t+0  nMarketType---------
    public static native byte[] nativeFunction1023(int nDevice, String payOrderID, int nAmout, String strTerminalId,
            String track2Data, String pin, String longitude, String latitude, String strCardSerialNo,
            String strICCardInfo, int nT0Flag, int nMarketType);

    public static native byte[] nativeFunction1024(int nDevice);

    public static native byte[] nativeFunction1025(int nDevice, String payOrderID, String strTerminalId,
            String strCardSerialNo, String strICCardInfo);

    public static native byte[] nativeFunction1026(int nDevice, String payOrderID, String pinpadID,
            String track2Data, String adminPassword, String longitude, String latitude, String strICFlag);

    public static native byte[] nativeFunction1027(int nDevice);

    public static native byte[] nativeFunction1028(int nDevice, String strPartnerId, String strUserName,
            String strUserPassword);

    public static native byte[] nativeFunction1029(int nDevice);

    public static native byte[] nativeFunction1030(int nDevice, String strUserName, String strMachId,
            String strPartnerId, String strToken, String strTimestamp, String strTokenSign, String strPayAmount,
            String strClientOrderId, String strClientContent);

    public static native byte[] nativeFunction1052(int nDevice);

    public static native byte[] nativeFunction1053(int nDevice, String strPayOrderID, String strLongitude,
            String strLatitude, String strTDCode, int t0flag);

    public static native byte[] nativeFunction2000(int nDevice);

    public static native byte[] nativeFunction2001(int nDevic, String question);

    public static native byte[] nativeFunction2002(int nDevice);

    public static native byte[] nativeFunction2003(int nDevice, String strDate);

    public static native byte[] nativeFunction2004(int nDevice);

    public static native byte[] nativeFunction2005(int nDevice, int strAmount);

    public static native byte[] nativeFunction2006(int nDevice);

    public static native byte[] nativeFunction2007(int nDevice);

    public static native byte[] nativeFunction2008(int nDevice);

    public static native byte[] nativeFunction2009(int nDevice, int nPageSize, int nPageNo, String strStartTime,
            String strEndTime);

    public static native byte[] nativeFunction2010(int nDevice);

    public static native byte[] nativeFunction2011(int nDevice, String merchantID, String payOrderID);

    public static native byte[] nativeFunction2012(int nDevice);

    public static native byte[] nativeFunction2013(int nDevice, String merchantID, String payOrderID,
            String cardHolderSign);

    public static native byte[] nativeFunction2014(int nDevice);

    public static native byte[] nativeFunction2015(int nDevice, String merchantID, String payOrderID,
            String emailAddress);

    public static native byte[] nativeFunction2016(int nDevice);

    public static native byte[] nativeFunction2017(int nDevice, String deviceType, String strDeviceId);

    public static native byte[] nativeFunction2018(int nDevice);

    public static native byte[] nativeFunction2019(int nDevice, String settlementMonth);

    public static native byte[] nativeFunction2020(int nDevice);

    public static native byte[] nativeFunction2021(int nDevice);

    public static native byte[] nativeFunction2022(int nDevice);

    public static native byte[] nativeFunction2023(int nDevice, String strUserName, String strMerchantID);

    public static native byte[] nativeFunction2024(int nDevice);

    /*pwd*/
    public static native byte[] nativeFunction2025(int nDevice, String strUserName, String strMerchantID,
            String strPinpadID, int nBind, String strPwd);

    public static native byte[] nativeFunction2026(int nDevice);

    public static native byte[] nativeFunction2027(int nDevice);

    public static native byte[] nativeFunction2028(int nDevice, String strMerchantID, String strPinPadList);

    public static native byte[] nativeFunction2029(int nDevice, int strAmount, String strThirdOrderID,
            String strReserve);

    public static native byte[] nativeFunction2030(int nDevice);

    public static native byte[] nativeFunction2031(int nDevice, int strAmount, String strGoodsType,
            String strGoodsName, String strGoodsDetail);

    public static native byte[] nativeFunction2034(int nDevice); // light add

    // wuhaoling
    /*modify by lucien for  nFlag 0  1 */
    public static native byte[] nativeFunction2035(int nDevice, String strMerchantID, String strMerchantSign,
            int nFlag);

    public static native byte[] nativeFunction2222(int device);

    public static native byte[] nativeFunction2223(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTrack2Data, String strTrack3Data, String strPIN,
            String strMachOrderId, int nTransactionAmount);

    public static native byte[] nativeFunction2223(int device);

    public static native byte[] nativeFunction2225(int device);

    public static native byte[] nativeFunction2226(int device);

    public static native byte[] nativeFunction2227(int device);

    public static native byte[] nativeFunction2228(int device);

    public static native byte[] nativeFunction2229(int device);

    public static native byte[] nativeFunction2230(int device);

    public static native byte[] nativeFunction2231(int device);

    public static native byte[] nativeFunction2232(int device);

    public static native byte[] nativeFunction2233(int device);

    public static native byte[] nativeFunction2234(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strOperatorPwd);

    public static native byte[] nativeFunction2235(int device, String strMachId, String strTerminalId,
            String strOperatorName);

    public static native byte[] nativeFunction2236(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTrack2Data, String strTrack3Data, String strPIN);

    public static native byte[] nativeFunction2237(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTrack2Data, String strTrack3Data, String strTransactionID,
            String strAdminPassword);

    public static native byte[] nativeFunction2238(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTrack2Data, String strTrack3Data, String strTransactionID,
            int nTransactionAmount, String strAdminPassword);

    public static native byte[] nativeFunction2239(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strPassword, String strAddOperatorName, String strAddOperatorPassword);

    public static native byte[] nativeFunction2240(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strPassword, String strDelOperatorName);

    public static native byte[] nativeFunction2241(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTranstactionId, int nSignInfoLength, String strSignContents);

    public static native byte[] nativeFunction3012(int device);

    public static native byte[] nativeFunction3013(int device, String strMachId, String strTerminalId,
            String strOperatorName);

    public static native byte[] nativeFunction3015(int device);

    public static native byte[] nativeFunction3020(int device);

    public static native byte[] nativeFunction3021(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTrack2Data, String strTrack3Data, String strPIN);

    public static native byte[] nativeFunction3022(int device);

    public static native byte[] nativeFunction3023(int device, String strMachId, String strTerminalId,
            String strOperatorName, String strTrack2Data, String strTrack3Data, String strPIN,
            String strMachOrderId, int nTransactionAmount);

    public static native byte[] nativeFunction10000(int nDevice, String strSecurityCommand,
            String strSubSecurityCommand);

    public static native byte[] nativeFunction10001(int nDevice, String strPlainData, boolean bAddUserInfo);

    //-------terence add 2016-03-09--------????

    public static native byte[] nativeFunction10008(int nDevice);

    public static native byte[] nativeFunction10009(int nDevice, String merchantId, String payOrderId,
            String transactionId, String cardHolderSign);

    /*jint nDevice,
    jstring strMerchantID,
    jstring strPayOrderID,
      jstring strTransactionID,
    jstring strCardHolderSign*/

    //-------terence add 2016-03-09--------???

    public static byte[] nativeFunction10010(int nDevice, String strNormalCommand) {
        return GetNormalCommandHead(strNormalCommand);
    }

    public static byte[] nativeFunction10011(int nDevice, String strPlainData) {
        if (strPlainData == null) {
            return GetOneCharData(nDevice);
        } else {
            return strPlainData.getBytes();
        }
    }

    // ===== Char add 2015-07-15 ?????
    public static native byte[] nativeFunction1054(int nDevice);

    public static native byte[] nativeFunction1055(int nDevice, String strCardID, String strCardBankCode,
            String strCardBankName, String strPayOrderID, String strPhoneNo, String strCardCVV,
            String strAccountName, String strCertType, String strCertID, String strVerifyCode, String strCardValid);

    public static native byte[] nativeFunction1056(int nDevice);

    public static native byte[] nativeFunction1057(int nDevice, String strCardID);

    public static native byte[] nativeFunction1058(int nDevice);

    public static native byte[] nativeFunction1059(int nDevice, String strPayOrderID, int nAmount,
            String strPinpadID, String strTrack2Data, String strPin, String strLongitude, String strLatitude,
            String strDiffuseFactor, int deviceType, int versionType, String strVerifyCode, String strGoodsName,
            String strNeedVerifyCode, int t0Flag);

    public static native byte[] nativeFunction1060(int nDevice);

    public static native byte[] nativeFunction1061(int nDevice);

    public static native byte[] nativeFunction1062(int nDevice);

    public static native byte[] nativeFunction1063(int nDevice, String strCardID);

    public static native byte[] nativeFunction1064(int nDevice);

    public static native byte[] nativeFunction1065(int nDevice, String strPayOrderID);

    public static native byte[] nativeFunction1066(int nDevice);

    public static native byte[] nativeFunction1067(int nDevice);

    public static native byte[] nativeFunction1068(int nDevice);

    public static native byte[] nativeFunction1069(int nDevice, String strPhoneNo, String checkCode);

    public static native byte[] nativeFunction2036(int nDevice);

    public static native byte[] nativeFunction2037(int nDevice, int nPageSize, int nPageNo, String strStartDate,
            String strEndDate, String strType);

    public static native byte[] nativeFunction1072(int nDevice);

    public static native byte[] nativeFunction1073(int nDevice, String strCardID, String strVerifyCode);

    // =====
    // =====Char add 2015-09-09 
    public static native byte[] nativeFunction1070(int nDevice);

    public static native byte[] nativeFunction1071(int nDevice, String strPayOrderID, int nAmount,
            String strLongitude, String strLatitude, String strCardID, String strGoodsName);

    // =====

    //? 
    public static native byte[] nativeFunction10002(int nDevice);

    public static native byte[] nativeFunction10003(int nDevice, String strPinpadID, String strTrack2Data,
            String strTrack3Data, String strPin, String strCardSerialNo, String strICCardInfo,
            String strDiffuseFactor, int deviceType);

    //? 
    public static native byte[] nativeFunction10004(int nDevice);

    //-----------terence add --2016-03-17 t+0 --------- 1  t+0,0 ?
    //-----------terence add --2016-05-13 t+0  nMarketType---------
    public static native byte[] nativeFunction10005(int nDevice, String strPayOrderID, int nAmount,
            String strPinpadID, String strTrack2Data, String strTrack3Data, String strPin, String strLongitude,
            String strLatitude, String strCardSerialNo, String strICCardInfo, String strDiffuseFactor,
            int deviceType, int nT0Flag, int nMarketType);

    //? 
    public static native byte[] nativeFunction10006(int nDevice);

    public static native byte[] nativeFunction10007(int nDevice, String strPayOrderID, String strPinpadID,
            String strTrack2Data, String strTrack3Data, String strAdminPassword, String strLongitude,
            String strLatitude, String strICFlag, String strDiffuseFactor, int deviceType);

    /*??? for*/
    public static native byte[] nativeFunction2038(int nDevice);

    public static native byte[] nativeFunction2039(int nDevice, String strPhoneNo);

    /*??*/
    public static native byte[] nativeFunction2040(int nDevice);

    public static native byte[] nativeFunction2041(int nDevice, String strPhoneNo, String strVerifyCode);

    public static byte[] GetNormalCommandHead(String pszCommand) {
        return (pszCommand + "|").getBytes();
    }

    public static byte[] GetOneCharData(int nDevice) {
        String strData = "1";
        return strData.getBytes();
    }

    private static String SECURITY_COMMAND = "1";

    // 
    private static String YKPAYSERVICE_SECURITY_SUB_ADD_AD_COMMAND = "2"; // 
    private static String YKPAYSERVICE_SECURITY_SUB_MODIFY_AD_COMMAND = "3"; // 
    private static String YKPAYSERVICE_SECURITY_SUB_BIND_OR_UNBIND_COMMAND = "5"; // /LED
    private static String YKPAYSERVICE_SECURITY_UPLOAD_AD_PLAY_COUNT_COMMAND = "6"; // 
    private static String YKPAYSERVICE_SECURITY_UPLOAD_AD_SYS_PLAY_COUNT_COMMAND = "13"; // 

    // ?
    private static String YKPAYSERVICE_QUERY_LED_DEVICE_LIST_COMMAND = "4";// 
    private static String YKPAYSERVICE_QUERY_LED_AD_LIST_COMMAND = "7";// 
    private static String YKPAYSERVICE_QUERY_LED_STATISTICS_DATA_COMMAND = "11";// ?
    private static String YKPAYSERVICE_QUERY_LED_SWITCH_PACKET_COMMAND = "14"; // ????
    private static String YKPAYSERVICE_QUERY_LED_SWITCH_AD_POSITION_COMMAND = "15"; // ???

    // 
    private static String YKPAYSERVICE_HONGBAO_BIND_OR_UNBIND_IBEACON_COMMAND = "20"; // /Ibeacon,??
    private static String YKPAYSERVICE_HONGBAO_ADD_HONGBAO_COMMAND = "21";
    private static String YKPAYSERVICE_HONGBAO_MODIFY_HONGBAO_STATUS_COMMAND = "23";
    private static String YKPAYSERVICE_HONGBAO_MODIFY_IBEACON_BIND_HONGBAO_LIST_COMMAND = "24";
    private static String YKPAYSERVICE_WECHAT_SHAKE_OPEN_COMMAND = "29"; // 
    private static String YKPAYSERVICE_UPLOAD_WECHAT_SHAKE_H5_PAGE_INFO_COMMAND = "32"; // /H5??
    private static String YKPAYSERVICE_OPERATE_IBEACON_H5_PAGES_COMMAND = "35"; // ?ibeacon??

    // ?
    private static String YKPAYSERVICE_QUERY_HONGBAO_LIST_COMMAND = "22";// 
    private static String YKPAYSERVICE_QUERY_HONGBAO_SEND_RECORD_LIST_COMMAND = "25"; //
    private static String YKPAYSERVICE_QUERY_HONGBAO_IBEACON_DEVICE_LIST_COMMAND = "26";// 
    private static String YKPAYSERVICE_QUERY_HONGBAO_STATISTICS_TOTAL_COMMAND = "28"; //
    private static String YKPAYSERVICE_UPLOAD_WECHAT_SHAKE_INFO_COMMAND = "30"; //
    private static String YKPAYSERVICE_QUERY_WECHAT_SHAKE_STATUE_COMMAND = "31"; //
    private static String YKPAYSERVICE_QUERY_WECHAT_SHAKE_H5_PAGE_INFO_COMMAND = "33"; // ?H5?????
    private static String YKPAYSERVICE_QUERY_H5PAGES_INFO_BY_IBEACON_COMMAND = "34"; // ????

    // ?
    private static String YKPAYSERVICE_BIND_GPRS_PRINTER_COMMAND = "30";
    private static String YKPAYSERVICE_VERIFY_GPRS_PRINTER_COMMAND = "31";
    private static String YKPAYSERVICE_UNBIND_GPRS_PRINTER_COMMAND = "32";
    private static String YKPAYSERVICE_GET_BIND_GPRS_PRINTER_LIST_COMMAND = "33";
    private static String YKPAYSERVICE_SET_GPRS_PRINTER_COMMAND = "34";
    private static String YKPAYSERVICE_GPRS_PRINTER_PRINT_DEAL_COMMAND = "35";

    // public static Vector<Device> devices = new Vector<Device>();
    public final static int APP_TYPE_ANDRIOD_LEPOS = 10000; // Andriod ?
    public final static int RUN_BY_APP = 0;
    public final static int CALL_BY_APP = 1;
    public final static int CALL_BY_WAP = 2;

    public final static int CALL_FOR_PAY_WITH_USERNAME_AND_PASSWORD = 0;
    public final static int CALL_FOR_USER_SHARE_LOGIN = 1;
    public final static int CALL_FOR_USER_SHARE_LOGIN_PAY = 2;
    public final static int CALL_FOR_O2O_PUSH_INFO = 3;

    public final static int THIRD_CALL_PAY_TYPE_READCARD = 0;
    public final static int THIRD_CALL_PAY_TYPE_WECHAT_BE_SCAN = 1;
    public final static int THIRD_CALL_PAY_TYPE_ALIPAY = 2;
    public final static int THIRD_CALL_PAY_TYPE_WECHAT_SCAN = 3;

    public final static String DEFALT_ERROR_CODE = "-6";
    public final static String DEFALT_ERROR_MSG = "";
    public final static String DEFALT_ERROR_TIP = "";

    static {
        System.loadLibrary("lepos");
    }

    public com.yeahka.android.leshua.Device getLeShuaDevice() {
        return leshuaDevice;
    }

    public Device() {
        shareAppData = Device.nativeFunction00000();
        device = Device.nativeFunction0(shareAppData);
        leshuaDevice = new com.yeahka.android.leshua.Device(shareAppData);
        leshuaDevice.setAppType(APP_TYPE);
    }

    public void setLocalDeviceId(String strLocalDeviceId) {
        this.strLocalDeviceId = strLocalDeviceId;
        leshuaDevice.setLocalDeviceId(strLocalDeviceId);
    }

    public void setLocalMobile(String strLocalMobile) {
        leshuaDevice.setLocalMobile(strLocalMobile);
    }

    public void setLocalIP(String strLocalIP) {
        leshuaDevice.setLocalIP(strLocalIP);
    }

    public ResultModel createCardTransOrder(String strCardTransCardId, String strCardTransBankBv,
            String strCardTransBankPv, String strCardTransBankCv, String strCardTransBankBrv,
            String strCardTransBankBn, String strCardTransCardMobile, String strCardTransCardHolder,
            Integer nCardTransCreateOrderAmout) {
        return leshuaDevice.createCardTransOrder(strCardTransCardId, strCardTransBankBv, strCardTransBankPv,
                strCardTransBankCv, strCardTransBankBrv, strCardTransBankBn, strCardTransCardMobile,
                strCardTransCardHolder, nCardTransCreateOrderAmout);
    }

    public ResultModel queryBankSupport() {
        return leshuaDevice.queryBankSupport();
    }

    public ResultModel tenpayNetOrderPayCheckCode() {
        return leshuaDevice.tenpayNetOrderPayCheckCode();
    }

    public void setLeposMachId(String leposMachId) {
        leshuaDevice.setLeposMachId(leposMachId);
    }

    public void setLeposMachOrderId(String leposMachOrderId) {
        leshuaDevice.setLeposMachOrderId(leposMachOrderId);
    }

    public ResultModel leshuaCreateLeposOrder() {
        return leshuaDevice.leshuaCreateLeposOrder();
    }

    public void setWifiStatus(boolean isWifiEnabled) {
        this.isWifiEnabled = isWifiEnabled;
        leshuaDevice.isWifiEnabled = isWifiEnabled;
    }

    public ResultModel setDevice2Volume(String strDevice2Volume) {
        byte[] data = Device.nativeFunction191(device, strDevice2Volume, android.os.Build.MODEL);
        return sendSecurityPackageToTransactionServerAndReturnResultModel(Device.nativeFunction190(device),
                Device.nativeFunction66(device), data);
    }

    public ResultModel queryNetPreordainOrder() {
        return leshuaDevice.queryNetPreordainOrder();
    }

    public ResultModel getMobileStorePreferentialInfo() {
        return leshuaDevice.getMobileStorePreferentialInfo();
    }

    public ResultModel resendAlipayCode(String strMachOrderID) {
        return leshuaDevice.resendAlipayCode(strMachOrderID);
    }

    public void setPinPadPayNotifyMobile(String strMobile) {
        leshuaDevice.setPinPadPayNotifyMobile(strMobile);
    }

    public ResultModel zhongciPayByLeshuaWithPinpad(String strPinpadID, String strTrack2Data, String strTrack3Data,
            String strPIN, String cardId, String randomNumber) {
        return leshuaDevice.zhongciPayByLeshuaWithPinpad(strPinpadID, strTrack2Data, strTrack3Data, strPIN, cardId,
                randomNumber);
    }

    public ResultModel zhongciICPayByLeshuaWithPinpad(String strPinpadID, String strTrack2Data, String strPIN,
            String cardId, String strCardSerialNo, String strICCardInfo, String randomNumber) {
        return leshuaDevice.zhongciICPayByLeshuaWithPinpad(strPinpadID, strTrack2Data, strPIN, strCardSerialNo,
                strICCardInfo, cardId, randomNumber);
    }

    public ResultModel payByLeshuaWithPinpad(String strPinpadID, String strTrack2Data, String strPIN,
            String strLongitude, String strLatitude, String cardId) {
        return leshuaDevice.payByLeshuaWithPinpad(strPinpadID, strTrack2Data, strPIN, strLongitude, strLatitude,
                cardId);
    }

    public ResultModel newPayByLeshuaWithPinpad(String strPinpadID, String strTrack2Data, String strPIN,
            String strLongitude, String strLatitude, String cardId) {
        return leshuaDevice.newPayByLeshuaWithPinpad(strPinpadID, strTrack2Data, strPIN, strLongitude, strLatitude,
                cardId);
    }

    public ResultModel ICCardPayByLeshuaWithPinpad(String strPinpadID, String strTrack2Data, String strPIN,
            String strLongitude, String strLatitude, String strCardSerialNo, String strICCardInfo, String cardId) {
        return leshuaDevice.ICCardPayByLeshuaWithPinpad(strPinpadID, strTrack2Data, strPIN, strLongitude,
                strLatitude, strCardSerialNo, strICCardInfo, cardId);
    }

    public ResultModel createLeShuaAlipayDirectRechargeOrder(String strAipayAccount, Integer nOrderPrice) {
        return leshuaDevice.createLeShuaAlipayDirectRechargeOrder(strAipayAccount, nOrderPrice);
    }

    public ResultModel downloadFangTeProductXml(String downloadFangTeGameProductIndex) {
        return leshuaDevice.downloadFangTeProductXml(downloadFangTeGameProductIndex);
    }

    public ResultModel createMobileStoreOrder() {
        return leshuaDevice.createMobileStoreOrder();
    }

    public ResultModel createLeShuaAlipayCodeStoreOrder(String strLeShuaAlipayCodeStoreUserMoblile,
            Integer nLeShuaAlipayCodeStoreAmount) {
        return leshuaDevice.createLeShuaAlipayCodeStoreOrder(strLeShuaAlipayCodeStoreUserMoblile,
                nLeShuaAlipayCodeStoreAmount);
    }

    public ResultModel createCreditCardRepaymentOrder(String strCreditCardRepaymentBankCode,
            String strCrditCardRepaymentCreateOrderCardNo, String strCrditCardRepaymentCreateOrderCardName,
            Integer nCrditCardRepaymentCreateOrderAmout, String strCreditCardRepaymentBankName) {
        return leshuaDevice.createCreditCardRepaymentOrder(strCreditCardRepaymentBankCode,
                strCrditCardRepaymentCreateOrderCardNo, strCrditCardRepaymentCreateOrderCardName,
                nCrditCardRepaymentCreateOrderAmout, strCreditCardRepaymentBankName);
    }

    public ResultModel createUserNetPreordainOrder() {
        return leshuaDevice.createUserNetPreordainOrder();
    }

    public ResultModel queryAppFeeRate() {
        return leshuaDevice.queryAppFeeRate();
    }

    public ResultModel queryCreditCardRepaymentBankList() {
        return leshuaDevice.queryCreditCardRepaymentBankList();
    }

    public ResultModel queryPayRecord() {
        return leshuaDevice.queryPayRecord();
    }

    public ResultModel queryOldPayRecord() {
        return leshuaDevice.queryOldPayRecord();
    }

    public ResultModel payForFastPayment() {
        return leshuaDevice.payForFastPayment();
    }

    public void setQueryPayRecordCount(int nQueryPayRecordCount) {
        leshuaDevice.setQueryPayRecordCount(nQueryPayRecordCount);
    }

    public int getQueryPayRecordCount() {
        return leshuaDevice.getQueryPayRecordCount();
    }

    public void setQueryPayRecordStartTime(String strQueryPayRecordStartTime) {
        leshuaDevice.setQueryPayRecordStartTime(strQueryPayRecordStartTime);
    }

    public void setQueryPayRecordEndTime(String strQueryPayRecordEndTime) {
        leshuaDevice.setQueryPayRecordEndTime(strQueryPayRecordEndTime);
    }

    public ResultModel submitFirstLoginData(String phoneDiviceId, String time) {
        return leshuaDevice.submitFirstLoginData(DEVICE_VERSION, phoneDiviceId, time);
    }

    public ResultModel checkTenpayIDAndName(String strTenpayID, String strTenpayName) {
        return leshuaDevice.checkTenpayIDAndName(strTenpayID, strTenpayName);
    }

    public ResultModel queryFangTeProductVersion() {
        return leshuaDevice.queryFangTeProductVersion();
    }

    public ResultModel queryFangTeProduct() {
        return leshuaDevice.queryFangTeProduct();
    }

    public void setGoodsName(String strGoodsName) {
        leshuaDevice.setGoodsName(strGoodsName);
    }

    public String getGoodsName() {
        return leshuaDevice.getGoodsName();
    }

    public void setQueryPreordainOrderID(String strQueryPreordainOrderID) {
        leshuaDevice.setQueryPreordainOrderID(strQueryPreordainOrderID);
    }

    public void setLeshuaPayOrderId(String strLeshuaPayOrderId) {
        leshuaDevice.setLeshuaPayOrderId(strLeshuaPayOrderId);
    }

    public String getLeshuaPayOrderId() {
        return leshuaDevice.getLeshuaPayOrderId();
    }

    public void setMachID(String machId) {
        leshuaDevice.setMachID(machId);
    }

    public void setMachOrderID(String machOrderId) {
        leshuaDevice.setMachOrderID(machOrderId);
    }

    public void setGoodsDetail(String strGoodsDetail) {
        leshuaDevice.setGoodsDetail(strGoodsDetail);
    }

    public String getGoodsDetail() {
        return leshuaDevice.getGoodsDetail();
    }

    public void setGoodsProvider(String strGoodsProvider) {
        leshuaDevice.setGoodsProvider(strGoodsProvider);
    }

    public String getGoodsProvider() {
        return leshuaDevice.getGoodsProvider();
    }

    public void setTransferAmount(int nTransferAmount) {
        leshuaDevice.setTransferAmount(nTransferAmount);
    }

    public void setTransferDeepAmount(int nTransferDeepAmount) {
        leshuaDevice.setTransferDeepAmount(nTransferDeepAmount);
    }

    public void setAmount(int nAmount) {
        leshuaDevice.setAmount(nAmount);
    }

    public int getAmount() {
        return leshuaDevice.getAmount();
    }

    public void setAmountString(String strAmountString) {
        leshuaDevice.setAmountString(strAmountString);
    }

    public String getAmountString() {
        return leshuaDevice.getAmountString();
    }

    public void setPayAmount(int nPayAmount) {
        leshuaDevice.setPayAmount(nPayAmount);
    }

    public int getPayAmount() {
        return leshuaDevice.getPayAmount();
    }

    public void setPayAmountString(String strPayAmountString) {
        leshuaDevice.setPayAmountString(strPayAmountString);
    }

    public String getPayAmountString() {
        return leshuaDevice.getPayAmountString();
    }

    public void setStoreApplicationID(String strStoreApplicationID) {
        leshuaDevice.setStoreApplicationID(strStoreApplicationID);
    }

    public String getStoreApplicationID() {
        return leshuaDevice.getStoreApplicationID();
    }

    public void setStoreApplicationUserID(String strStoreApplicationUserID) {
        leshuaDevice.setStoreApplicationUserID(strStoreApplicationUserID);
    }

    public String getStoreApplicationUserID() {
        return leshuaDevice.getStoreApplicationUserID();
    }

    public void setStoreApplicationUserName(String strStoreApplicationUserName) {
        leshuaDevice.setStoreApplicationUserName(strStoreApplicationUserName);
    }

    public String getStoreApplicationUserName() {
        return leshuaDevice.getStoreApplicationUserName();
    }

    public void setSourceDir(String strSourceDir) {
        Device.nativeFunction5(device, strSourceDir);
    }

    public void setAppType(int nAppType) {
        Device.nativeFunction32(device, nAppType);
    }

    private ResultModel sendLoginPackageToLoginServer(byte[] data1, byte[] data2) {
        int nResult = 0;
        ResultModel resModel = sendDataToServer(LOGIN_SERVER_PROXY, data1, data2);

        if (resModel.getResultStatus() != 0) {
            return resModel;
        }
        byte[] recvData = resModel.getOtherInfo();

        nResult = Device.nativeFunction103(device, recvData);

        return new ResultModel(nResult);
    }

    private ResultModel sendSecurityPackageToTransactionServerAndReturnResultModel(byte[] head, int nPackage,
            byte[] data) {
        return sendDataToServer(TRANSACTION_SERVER_PROXY, head, intToFourByte(nPackage), data);
    }

    private ResultModel sendCommandPackageToTransactionServerAndReturnResultModel(byte[] command, byte[] data) {
        byte[] padding = new byte[1];
        return sendDataToServer(TRANSACTION_SERVER_PROXY, command, intToFourByte(data.length), data, padding);
    }

    private ResultModel sendCommandPackageToLedServerAndReturnResultModel(byte[] command, byte[] data) {
        byte[] padding = new byte[1];
        return sendDataToServer(LED_SERVER_PROXY, command, intToFourByte(data.length), data, padding);
    }

    private ResultModel sendSecurityPackageToLedServerAndReturnResultModel(byte[] head, int nPackage, byte[] data) {
        return sendDataToServer(LED_SERVER_PROXY, head, intToFourByte(nPackage), data);
    }

    private ResultModel sendCommandPackageToHongbaoServerAndReturnResultModel(byte[] command, byte[] data) {
        byte[] padding = new byte[1];
        return sendDataToServer(HONGBAO_SERVER_PROXY, command, intToFourByte(data.length), data, padding);
    }

    private ResultModel sendSecurityPackageToHongbaoServerAndReturnResultModel(byte[] head, int nPackage,
            byte[] data) {
        return sendDataToServer(HONGBAO_SERVER_PROXY, head, intToFourByte(nPackage), data);
    }

    private ResultModel sendCommandPackageToGprsPrintServerAndReturnResultModel(byte[] command, byte[] data) {
        byte[] padding = new byte[1];
        return sendDataToServer(GPRS_PRINTER_SERVER_PROXY, command, intToFourByte(data.length), data, padding);
    }

    private ResultModel sendSecurityPackageToGprsPrintServerAndReturnResultModel(byte[] head, int nPackage,
            byte[] data) {
        return sendDataToServer(GPRS_PRINTER_SERVER_PROXY, head, intToFourByte(nPackage), data);
    }

    private ResultModel sendCommandPackageToLeShuaTransactionServerAndReturnXmlResultModel(byte[] command,
            byte[] data) {
        byte[] padding = new byte[1];
        return sendDataToServer(TRANSACTION_SERVER_PROXY, command, intToFourByte(data.length), data, padding);
    }

    private ResultModel sendDataToServer(int proxy, byte[] data1, byte[] data2) {
        byte[] sendData = Device.nativeFunction59(device, data1, data2);
        return sendRawDataToServer(proxy, sendData);
    }

    private ResultModel sendDataToServer(int proxy, byte[] data1, byte[] data2, byte[] data3) {
        byte[] sendData = Device.nativeFunction60(device, data1, data2, data3);
        return sendRawDataToServer(proxy, sendData);
    }

    private ResultModel sendDataToServer(int proxy, byte[] data1, byte[] data2, byte[] data3, byte[] data4) {
        byte[] sendData = Device.nativeFunction61(device, data1, data2, data3, data4);
        return sendRawDataToServer(proxy, sendData);
    }

    private int fourByteToInt(byte[] fourByte, int nIndex) {
        int nData = fourByte[nIndex + 3] & 0xFF;
        nData = (nData << 8) + (fourByte[nIndex + 2] & 0xFF);
        nData = (nData << 8) + (fourByte[nIndex + 1] & 0xFF);
        nData = (nData << 8) + (fourByte[nIndex + 0] & 0xFF);
        return nData;
    }

    private byte[] intToFourByte(int n) {
        byte[] data = new byte[4];
        data[0] = (byte) (n & 0xFF);
        data[1] = (byte) ((n >> 8) & 0xFF);
        data[2] = (byte) ((n >> 16) & 0xFF);
        data[3] = (byte) ((n >> 24) & 0xFF);
        return data;
    }

    // public void sendCrashReport(String strCrashReport)
    // {
    // sendCommandPackageToTransactionServer(Device.nativeFunction127(device),
    // Device.nativeFunction128(device, strCrashReport));
    // }
    public void closeDevice() {
        Device.nativeFunction1(device);
        Device.nativeFunction00001(shareAppData);
    }

    private final int LOGIN_OPEN_POS_ACTION = 1;
    private final int LOGOUT_OPEN_POS_ACTION = 2;
    private final int CHECK_CARD_BALANCE_OPEN_POS_ACTION = 3;
    private final int PAY_REQUEST_OPEN_POS_ACTION = 4;
    private final int ANNUL_TRANS_REQUEST_OPEN_POS_ACTION = 5;
    private final int ANNUL_GOODS_REQUEST_OPEN_POS_ACTION = 6;
    private final int QUERY_LOG_OPEN_POS_ACTION = 7;
    private final int QUERY_TRANS_NOTE_OPEN_POS_ACTION = 8;
    private final int REGISTER_USER_OPEN_POS_ACTION = 9;
    private final int UNREGISTER_USER_OPEN_POS_ACTION = 10;
    private final int CHANGE_PASSWORD_OPEN_POS_ACTION = 11;
    private final int QUERY_TRANS_AMOUNT_OPEN_POS_ACTION = 12;
    private final int SEND_SIGN_PIC__OPEN_POS_ACTION = 13;
    private final int SEND_CAMERA_PIC__OPEN_POS_ACTION = 14;

    public ResultModel queryMachBindLeposDeviceList(String strUserName, String strMerchantID) {
        byte[] head = Device.nativeFunction2022(device);
        byte[] body = Device.nativeFunction2023(device, strUserName, strMerchantID);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    /*  ?*/
    public ResultModel machBindLeposDevice(String strUserName, String strMerchantID, String strPinpadID) {
        byte[] head = Device.nativeFunction2024(device);
        byte[] body = nativeFunction2025(device, strUserName, strMerchantID, strPinpadID, 1, "");

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel machBindLeposDeviceForTradition(String strUserName, String strMerchantID,
            String strPinpadID) {
        byte[] head = Device.nativeFunction2024(device);
        byte[] body = nativeFunction2025(device, strUserName, strMerchantID, strPinpadID, 11, "");

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel machUnBindLeposDevice(String strUserName, String strMerchantID, String strPinpadID,
            String strPwd) {
        byte[] head = Device.nativeFunction2024(device);
        byte[] body = nativeFunction2025(device, strUserName, strMerchantID, strPinpadID, 0, strPwd);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel userFeedBack(String strQuestion) {
        byte[] head = Device.nativeFunction2000(device);
        byte[] body = Device.nativeFunction2001(device, strQuestion);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel queryUserFeedBack(String strDate) {
        byte[] head = Device.nativeFunction2002(device);
        byte[] body = Device.nativeFunction2003(device, strDate);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public void setUserName(String strUserName) {
        Device.nativeFunction105(device, strUserName);
        leshuaDevice.setUserName(strUserName);
    }

    public void setSessionID(String strSessionID) {
        Device.nativeFunction106(device, strSessionID);
    }

    public void setMerchantId(String strMerchantId) {
        Device.nativeFunction107(device, strMerchantId);
    }

    public ResultModel checkVersion(String strUserName) {
        try {

            leshuaDevice.checkVersion(simSerialNumber);
            ResultModel resModel = sendDataToServer(LOGIN_SERVER_PROXY, Device.nativeFunction2(device),
                    Device.nativeFunction3(device, simSerialNumber, DEVICE_VERSION, strUserName));

            if (resModel.getResultStatus() != 0) {
                return resModel;
            }
            byte[] recvData = resModel.getOtherInfo();

            int nMinVersion = fourByteToInt(recvData, 0);
            int nMaxVersion = fourByteToInt(recvData, 4);

            int nFactor1 = fourByteToInt(recvData, 8);
            int nFactor2 = fourByteToInt(recvData, 12);
            int nFactor3 = fourByteToInt(recvData, 16);
            Device.nativeFunction4(device, nFactor1, nFactor2, nFactor3);

            byte[] showUpdateTipByteArray = new byte[recvData.length - 20];
            System.arraycopy(recvData, 20, showUpdateTipByteArray, 0, showUpdateTipByteArray.length);
            String strShowUpdateTip = new String(showUpdateTipByteArray, "UTF-8");

            if (APP_NETWORK_ENVIRONMENT_FLAG == 1) {
                System.out.println("??? = " + nMinVersion);
                System.out.println("?? = " + nMaxVersion);
                System.out.println("? = " + DEVICE_VERSION);
                if (DEVICE_VERSION < nMinVersion) {
                    ResultModel resultModel = new ResultModel(APP_MUST_UPDATE_ERROR);
                    resultModel.setKey("updateTip", strShowUpdateTip);
                    return resultModel;
                } else if (DEVICE_VERSION < nMaxVersion) {
                    ResultModel resultModel = new ResultModel(APP_SHOULD_UPDATE_ERROR);
                    resultModel.setKey("updateTip", strShowUpdateTip);
                    return resultModel;
                } else {
                    return new ResultModel(0);
                }
            } else {
                return new ResultModel(0);
            }
        } catch (Exception ex) {
            return new ResultModel(Device.SYSTEM_FAIL);
        }
    }

    /**
     * ??
     *
     * @param url
     * @return
     * @author "Char"
     * @create_date 2015-9-23
     */
    public ResultModel getDownloadApkUrl(String url) {
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel login(Application application) {
        // synchronized (Device.devices) {
        StringBuilder machineBuilder = new StringBuilder();
        machineBuilder.append("Android:");
        machineBuilder.append(android.os.Build.MODEL);
        machineBuilder.append(":");
        machineBuilder.append(android.os.Build.VERSION.SDK);
        machineBuilder.append(":");
        machineBuilder.append(android.os.Build.VERSION.RELEASE);
        return sendLoginPackageToLoginServer(Device.nativeFunction67(device),
                Device.nativeFunction68(device, simSerialNumber, machineBuilder.toString(), application));
        // }
    }

    public ResultModel userLogin(String strUsername, String strPassword) {
        byte[] head = Device.nativeFunction1000(device);
        byte[] body = Device.nativeFunction1001(device, strUsername, strPassword);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    /*add by lucien ??*/
    public ResultModel userLoginByVerifyCode(String phoneNo, String verifyCode) {
        byte[] head = Device.nativeFunction2040(device);
        byte[] body = Device.nativeFunction2041(device, phoneNo, verifyCode);
        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    /*add by lucien ????*/
    public ResultModel sendVerifyCodeForLogin(String phoneNo) {
        byte[] head = Device.nativeFunction2038(device);
        byte[] body = Device.nativeFunction2039(device, phoneNo);
        //        MyLog.d("user_login", "userLogin :phoneNo = " + phoneNo + " device = " + device);
        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel orderQuery(Integer nPageSize, Integer nPageNo, String strStartTime, String strEndTime) {
        //        MyLog.d("OrderCenter", "pageSize=" + nPageSize + "pageNumber=" + nPageNo + "startTime=" +
        //                strStartTime + "pageEndTime=" + strEndTime);
        byte[] head = Device.nativeFunction2008(device);
        byte[] body = Device.nativeFunction2009(device, nPageSize, nPageNo, strStartTime, strEndTime);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel querySpecificOrderInfo(String merchantID, String strPayOrderId) {
        //        MyLog.info("Order Center", "merchantId=" + merchantID + "strPayOrderId=" + strPayOrderId);
        byte[] head = Device.nativeFunction2010(device);
        byte[] body = Device.nativeFunction2011(device, merchantID, strPayOrderId);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel userLogout() {
        byte[] head = Device.nativeFunction1002(device);
        byte[] body = Device.nativeFunction1003(device);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    /**
     * ? 
     *
     * @param strPayOrderID
     * @param strPinpadID
     * @param strTrack2Data
     * @param strTrack3Data
     * @param strAdminPassword
     * @param strLongitude
     * @param strLatitude
     * @param strICFlag
     * @param strDiffuseFactor
     * @param deviceType
     * @return
     */
    public ResultModel zhognciRevokeTransRequest(String strPayOrderID, String strPinpadID, String strTrack2Data,
            String strTrack3Data, String strAdminPassword, String strLongitude, String strLatitude,
            String strICFlag, String strDiffuseFactor, Integer deviceType) {
        byte[] head = Device.nativeFunction10006(device);
        byte[] body = Device.nativeFunction10007(device, strPayOrderID, strPinpadID, strTrack2Data, strTrack3Data,
                strAdminPassword, strLongitude, strLatitude, strICFlag, strDiffuseFactor, deviceType);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel revokeTransRequest(String strMachOrderId, String strTerminalId, String strTrackData,
            String strAdminPassword, String strLongitude, String strLatitude) {
        byte[] head = Device.nativeFunction1010(device);
        byte[] body = Device.nativeFunction1011(device, strMachOrderId, strTerminalId, strTrackData,
                strAdminPassword, strLongitude, strLatitude);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel ICCardRevokeTransRequest(String strMachOrderId, String strTerminalId, String strTrackData,
            String strAdminPassword, String strLongitude, String strLatitude) {
        byte[] head = Device.nativeFunction1010(device);
        byte[] body = Device.nativeFunction1026(device, strMachOrderId, strTerminalId, strTrackData,
                strAdminPassword, strLongitude, strLatitude, "1");

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel annulGoodsRequest(String strMachId, String strTerminalId, String strOperatorName,
            String strTrack2Data, String strTrack3Data, String strTranstactionId, Integer nFallBackAmount,
            String strAdminPassword) {
        byte[] head = Device.nativeFunction2228(device);
        byte[] body = Device.nativeFunction2238(device, strMachId, strTerminalId, strOperatorName, strTrack2Data,
                strTrack3Data, strTranstactionId, nFallBackAmount, strAdminPassword);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel checkCardBalance(String strTerminalId, String strTrackData, String strPIN) {
        byte[] head = Device.nativeFunction1006(device);
        byte[] body = Device.nativeFunction1007(device, strTerminalId, strTrackData, strPIN);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    /**
     * ??
     *
     * @param strPinpadID
     * @param strTrack2Data
     * @param strTrack3Data
     * @param strPin
     * @param strCardSerialNo
     * @param strICCardInfo
     * @param strDiffuseFactore
     * @param deviceType
     * @return
     */
    public ResultModel checkCardBalanceByZhongci(String strPinpadID, String strTrack2Data, String strTrack3Data,
            String strPin, String strCardSerialNo, String strICCardInfo, String strDiffuseFactore,
            Integer deviceType) {
        byte[] head = Device.nativeFunction10002(device);
        byte[] body = Device.nativeFunction10003(device, strPinpadID, strTrack2Data, strTrack3Data, strPin,
                strCardSerialNo, strICCardInfo, strDiffuseFactore, deviceType);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel checkICCardBalance(String strTerminalId, String strTrackData, String strPIN,
            String strCardSerialNo, String strICCardInfo) {
        byte[] head = Device.nativeFunction1006(device);
        byte[] body = Device.nativeFunction1022(device, strTerminalId, strTrackData, strPIN, strCardSerialNo,
                strICCardInfo);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel upLoadDownCardResult(String payOrderID, String strTerminalId, String strCardSerialNo,
            String strICCardInfo) {
        byte[] head = Device.nativeFunction1024(device);
        byte[] body = Device.nativeFunction1025(device, payOrderID, strTerminalId, strCardSerialNo, strICCardInfo);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    //-----------terence add --2016-03-17 t+0 ---------
    //-----------terence add --2016-05-16  ---------
    public ResultModel payRequest(String strMachOrderId, Integer nTransactionAmount, String strTerminalId,
            String strTrackData, String strPIN, String strLongitude, String strLatitude, int t0Flag,
            int markedType) {
        byte[] head = Device.nativeFunction1008(device);
        byte[] body = Device.nativeFunction1009(device, strMachOrderId, nTransactionAmount, strTerminalId,
                strTrackData, strPIN, strLongitude, strLatitude, t0Flag, markedType);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel queryWechatPayResult(String strMachOrderId, String strLongitude, String strLatitude) {
        byte[] head = Device.nativeFunction1014(device);
        byte[] body = Device.nativeFunction1015(device, strMachOrderId, strLongitude, strLatitude);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel getWechatPayTdCode(String strMachOrderId, String strLongitude, String strLatitude,
            Integer t0Flag) {
        byte[] head = Device.nativeFunction1012(device);
        byte[] body = Device.nativeFunction1013(device, strMachOrderId, strLongitude, strLatitude, t0Flag);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    /* t0 20160729*/
    public ResultModel payByWechatPayTdCode(String strMachOrderId, String strLongitude, String strLatitude,
            String strTrcode, Integer t0Flag) {
        byte[] head = Device.nativeFunction1052(device);
        byte[] body = Device.nativeFunction1053(device, strMachOrderId, strLongitude, strLatitude, strTrcode,
                t0Flag);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel queryAlipayPayResult(String strMachOrderId, String strLongitude, String strLatitude) {
        byte[] head = Device.nativeFunction1018(device);
        byte[] body = Device.nativeFunction1019(device, strMachOrderId, strLongitude, strLatitude);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel getAlipayPayTdCode(String strMachOrderId, String strLongitude, String strLatitude) {
        byte[] head = Device.nativeFunction1016(device);
        byte[] body = Device.nativeFunction1017(device, strMachOrderId, strLongitude, strLatitude);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    //-----------terence add --2016-03-17 t+0 ---------
    //-----------terence add --2016-05-16   marketType---------
    public ResultModel payRequest(String strMachOrderId, Integer nTransactionAmount, String strTerminalId,
            String strTrackData, String strPIN, String strLongitude, String strLatitude, String host, Integer port,
            Integer nT0Flag, Integer marketType) {
        byte[] head = Device.nativeFunction1008(device);
        byte[] body = Device.nativeFunction1009(device, strMachOrderId, nTransactionAmount, strTerminalId,
                strTrackData, strPIN, strLongitude, strLatitude, nT0Flag, marketType);
        byte[] sendData = Device.nativeFunction60(device, head, intToFourByte(Device.nativeFunction66(device)),
                body);
        InetAddress address;
        try {
            address = InetAddress.getByName(host);
            Socket socket = new Socket(address, port);
            socket.setKeepAlive(true);// ????
            socket.setSoTimeout(60 * 1000);// 
            OutputStream out = socket.getOutputStream();
            out.write(sendData);
            out.flush();
            InputStream input = socket.getInputStream();
            boolean bGetHead = ServerSocketConnectUtil.getHead(socket);
            if (bGetHead == false) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            byte[] bytes = new byte[4];
            int length = input.read(bytes);
            if (length != 4) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            ByteArrayReader bar = new ByteArrayReader(bytes);
            int dataLength = bar.readIntLowByteFirst();
            if (dataLength < 0) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            bytes = new byte[dataLength];
            length = input.read(bytes);
            if (length != dataLength) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            String sc = new String(bytes, "UTF-8");
            return new ResultModel(sc);
        } catch (UnknownHostException e) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (SocketException e1) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (IOException e2) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        }

    }

    //-----------terence add --2016-03-17 t+0 ---------
    //-----------terence add --2016-05-16   marketType---------
    public ResultModel newPayRequest(String strMachOrderId, Integer nTransactionAmount, String strTerminalId,
            String strTrackData, String strPIN, String strLongitude, String strLatitude, String host, Integer port,
            Integer nT0Flag, Integer marketType) {
        if (YeahkaDevice.getDeviceVersionType() == YeahkaDevice.DEVICE_VERSION_TYPE_PIN_WITH_OPERATE) {
            if (!TextUtils.isEmpty(strPIN)) {
                strPIN = strPIN + PIN_BACK;
            }
        }
        byte[] head = Device.nativeFunction1020(device);
        byte[] body = Device.nativeFunction1021(device, strMachOrderId, nTransactionAmount, strTerminalId,
                strTrackData, strPIN, strLongitude, strLatitude, nT0Flag, marketType);
        byte[] sendData = Device.nativeFunction60(device, head, intToFourByte(Device.nativeFunction66(device)),
                body);
        InetAddress address;
        try {
            address = InetAddress.getByName(host);
            Socket socket = new Socket(address, port);
            socket.setKeepAlive(true);// ????
            socket.setSoTimeout(60 * 1000);// 
            OutputStream out = socket.getOutputStream();
            out.write(sendData);
            out.flush();
            InputStream input = socket.getInputStream();
            boolean bGetHead = ServerSocketConnectUtil.getHead(socket);
            if (bGetHead == false) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            byte[] bytes = new byte[4];
            int length = input.read(bytes);
            if (length != 4) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            ByteArrayReader bar = new ByteArrayReader(bytes);
            int dataLength = bar.readIntLowByteFirst();
            if (dataLength < 0) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            bytes = new byte[dataLength];
            length = input.read(bytes);
            if (length != dataLength) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            String sc = new String(bytes, "UTF-8");
            return new ResultModel(sc);
        } catch (UnknownHostException e) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (SocketException e1) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (IOException e2) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        }

    }

    //-----------terence add --2016-05-16   marketType---------
    public ResultModel ICCardPayRequest(String strMachOrderId, Integer nTransactionAmount, String strTerminalId,
            String strTrackData, String strPIN, String strLongitude, String strLatitude, String host, Integer port,
            String strCardSerialNo, String strICCardInfo, Integer nT0Flag, Integer marketType) {
        if (YeahkaDevice.getDeviceVersionType() == YeahkaDevice.DEVICE_VERSION_TYPE_PIN_WITH_OPERATE) {
            if (!TextUtils.isEmpty(strPIN)) {
                strPIN = strPIN + PIN_BACK;
            }
        }

        //        MyLog.info("mDealMode=", nT0Flag + "");
        byte[] head = Device.nativeFunction1020(device);
        byte[] body = Device.nativeFunction1023(device, strMachOrderId, nTransactionAmount, strTerminalId,
                strTrackData, strPIN, strLongitude, strLatitude, strCardSerialNo, strICCardInfo, nT0Flag,
                marketType);
        byte[] sendData = Device.nativeFunction60(device, head, intToFourByte(Device.nativeFunction66(device)),
                body);
        InetAddress address;
        try {
            address = InetAddress.getByName(host);
            Socket socket = new Socket(address, port);
            socket.setKeepAlive(true);// ????
            socket.setSoTimeout(60 * 1000);// 
            OutputStream out = socket.getOutputStream();
            out.write(sendData);
            out.flush();
            InputStream input = socket.getInputStream();
            boolean bGetHead = ServerSocketConnectUtil.getHead(socket);
            if (bGetHead == false) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            byte[] bytes = new byte[4];
            int length = input.read(bytes);
            if (length != 4) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            ByteArrayReader bar = new ByteArrayReader(bytes);
            int dataLength = bar.readIntLowByteFirst();
            if (dataLength < 0) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            bytes = new byte[dataLength];
            length = input.read(bytes);
            if (length != dataLength) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            String sc = new String(bytes, "UTF-8");
            return new ResultModel(sc);
        } catch (UnknownHostException e) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (SocketException e1) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (IOException e2) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        }
    }

    /**
     * ??
     *
     * @param strOrderID
     * @param amount
     * @param strPinpadID
     * @param strTrack2Data
     * @param strTrack3Data
     * @param strPin
     * @param strLongitude
     * @param strLatitude
     * @param strCardSerialNo
     * @param strICCardInfo
     * @param strDiffuseFactor
     * @param deviceType
     * @param host
     * @param port
     * @return
     */
    //-----------terence add --2016-03-17 t+0 ---------
    //-----------terence add --2016-05-16   marketType---------
    public ResultModel zhongciPayRequest(String strOrderID, Integer amount, String strPinpadID,
            String strTrack2Data, String strTrack3Data, String strPin, String strLongitude, String strLatitude,
            String strCardSerialNo, String strICCardInfo, String strDiffuseFactor, Integer deviceType, String host,
            Integer port, Integer nT0Flag, Integer marketType) {
        if (YeahkaDevice.getDeviceVersionType() == YeahkaDevice.DEVICE_VERSION_TYPE_PIN_WITH_OPERATE) {
            if (!TextUtils.isEmpty(strPin)) {
                strPin = strPin + PIN_BACK;
            }
        }
        //        String tag = "zhongciPayRequest";
        byte[] head = Device.nativeFunction10004(device);
        byte[] body = Device.nativeFunction10005(device, strOrderID, amount, strPinpadID, strTrack2Data,
                strTrack3Data, strPin, strLongitude, strLatitude, strCardSerialNo, strICCardInfo, strDiffuseFactor,
                deviceType, nT0Flag, marketType);
        byte[] sendData = Device.nativeFunction60(device, head, intToFourByte(Device.nativeFunction66(device)),
                body);
        InetAddress address;
        try {
            address = InetAddress.getByName(host);
            Socket socket = new Socket(address, port);
            socket.setKeepAlive(true);// ????
            socket.setSoTimeout(60 * 1000);// 
            OutputStream out = socket.getOutputStream();
            out.write(sendData);
            out.flush();
            InputStream input = socket.getInputStream();
            boolean bGetHead = ServerSocketConnectUtil.getHead(socket);
            if (bGetHead == false) {
                //                MyLog.d(TAG, "get head =" + bGetHead);
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            byte[] bytes = new byte[4];
            int length = input.read(bytes);
            if (length != 4) {
                //                MyLog.d(TAG, "len is not 4 ");
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            ByteArrayReader bar = new ByteArrayReader(bytes);
            int dataLength = bar.readIntLowByteFirst();
            if (dataLength < 0) {
                //                MyLog.d(TAG, "data len less than 0 ");
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            bytes = new byte[dataLength];
            length = input.read(bytes);
            if (length != dataLength) {
                //                MyLog.d(TAG, "len not equal data lenth ");
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            String sc = new String(bytes, "UTF-8");
            return new ResultModel(sc);
        } catch (UnknownHostException e) {
            e.printStackTrace();
            MyLog.d(TAG, "UnknownHostException ");
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (SocketException e1) {
            e1.printStackTrace();
            MyLog.d(TAG, "SocketException ");
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (IOException e2) {
            e2.printStackTrace();
            MyLog.d(TAG, "IOException ");
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        }

    }

    public byte[] entryptTLVData(String json, boolean bAddUserInfo) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND, "1");

        byte[] data = Device.nativeFunction10001(device, json, bAddUserInfo);
        int nPackage = Device.nativeFunction66(device);
        return Device.nativeFunction60(device, command, intToFourByte(nPackage), data);
        // return sendSecurityPackageToCashierServerAndReturnData(command,
        // Device.nativeFunction66(device), data);

    }

    private String getOADJsonStr(Object data, String object, String action) {
        Gson gson = new Gson();
        // String jsonStr = "";
        // // if(para != null){
        // // jsonStr = gson.toJson(para);
        // // }

        BaseOADBean oda = new BaseOADBean();
        oda.setO(object);
        oda.setA(action);
        oda.setD(data);
        return gson.toJson(oda);
    }

    private String getOADJsonStr(String object, String action) {
        Gson gson = new Gson();
        // String jsonStr = "";
        // // if(para != null){
        // // jsonStr = gson.toJson(para);
        // // }

        BaseOADBean oda = new BaseOADBean();
        oda.setO(object);
        oda.setA(action);
        oda.setD("");
        return gson.toJson(oda);
    }

    private byte[] getTLVPackaget(String jsonStr, boolean bAddUserInfo) {
        TLVBase base = new TLVBase();
        TLVHead head = new TLVHead();
        TLVEncryptBody encryptBody = new TLVEncryptBody();
        TLVJson body = new TLVJson();

        byte[] sendData = entryptTLVData(jsonStr, bAddUserInfo); // leshuaDevice.entryptTLVData(jsonStr2);

        // String str1 = Util.bytesToHexString(sendData);
        // Log.i("resigter", "rigsterPrinceCity/str1=" +
        // str1.replaceAll("(.{8})", "$1 "));

        body.setV(sendData);

        byte[] bodyData = body.toTLVBytes();
        encryptBody.setV(bodyData);

        head.setV();
        byte[] headData = head.toTLVBytes();

        byte[] encryData = encryptBody.toTLVBytes();

        byte[] baseData = new byte[encryData.length + headData.length];
        System.arraycopy(headData, 0, baseData, 0, headData.length);
        System.arraycopy(encryData, 0, baseData, headData.length, encryData.length);
        base.setV(baseData);

        return base.toTLVBytes();
    }

    private byte[] getTLVPackaget(String jsonStr, boolean bAddUserInfo, TLVBytes... objects) {
        TLVBase base = new TLVBase();
        TLVHead head = new TLVHead();
        TLVEncryptBody encryptBody = new TLVEncryptBody();
        TLVJson body = new TLVJson();

        byte[] sendData = entryptTLVData(jsonStr, bAddUserInfo);

        // String str1 = Util.bytesToHexString(sendData);
        // Log.i("resigter", "rigsterPrinceCity/str1=" +
        // str1.replaceAll("(.{8})", "$1 "));

        body.setV(sendData);

        byte[] bodyData = body.toTLVBytes();
        encryptBody.setV(bodyData);

        head.setV();
        byte[] headData = head.toTLVBytes();

        byte[] encryData = encryptBody.toTLVBytes();

        int length = encryData.length + headData.length;
        for (TLVBytes tlv : objects) {
            length += tlv.getL() + 8;
        }

        byte[] baseData = new byte[length];
        System.arraycopy(headData, 0, baseData, 0, headData.length);
        System.arraycopy(encryData, 0, baseData, headData.length, encryData.length);
        int index = encryData.length + headData.length;
        for (TLVBytes tlv : objects) {
            byte[] bytes = tlv.toTLVBytes();
            System.arraycopy(bytes, 0, baseData, index, bytes.length);
            index += bytes.length;
        }

        base.setV(baseData);

        return base.toTLVBytes();
    }

    private byte[] getTLVPackagetO2O(String jsonStr, boolean bAddUserInfo, TLVBytes... objects) {
        TLVBase base = new TLVBase();
        TLVHead head = new TLVHead();
        TLVJson body = new TLVJson();
        byte[] sendData = jsonStr.getBytes();
        body.setV(sendData);
        byte[] bodyData = body.toTLVBytes();

        head.setV();
        byte[] headData = head.toTLVBytes();

        int length = bodyData.length + headData.length;
        for (TLVBytes tlv : objects) {
            length += tlv.getL() + 8;
        }

        byte[] baseData = new byte[length];
        System.arraycopy(headData, 0, baseData, 0, headData.length);
        System.arraycopy(bodyData, 0, baseData, headData.length, bodyData.length);
        int index = bodyData.length + headData.length;
        for (TLVBytes tlv : objects) {
            byte[] bytes = tlv.toTLVBytes();
            System.arraycopy(bytes, 0, baseData, index, bytes.length);
            index += bytes.length;
        }

        base.setV(baseData);

        return base.toTLVBytes();
    }

    public ResultModel queryCheckingLicence(String UserName) {

        CheckLicenceBean bean = new CheckLicenceBean();
        bean.setUser_name(UserName);
        bean.setApp_type("1");
        String object = "Base_Info";
        String action = "Query_Checking_Licence";
        String jsonStr = getOADJsonStr(bean, object, action);
        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, ResponseCheckLicenseBean.class);
    }

    public ResultModel rigsterPrinceCity() {
        String object = "Base_Info";
        String action = "Query_PC";
        String jsonStr = getOADJsonStr(object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDProvinceCity.class);
    }

    public ResultModel merchantBaseInfo(String user_name, String mobile) {
        OADUserBean bean = new OADUserBean();
        bean.setMobile(mobile);
        bean.setUser_name(user_name);

        String object = "Merchant_Base_Info";
        String action = "Query";
        String jsonStr = getOADJsonStr(bean, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    public ResultModel requestRegister(String register_type, String user_name, String mobile, String applicant,
            String province_no, String province_name, String city_no, String city_name, String address) {
        OADRequestRegister bean = new OADRequestRegister();
        bean.setMobile(mobile);
        bean.setUser_name(user_name);
        bean.setRegister_type(register_type);
        bean.setProvince_no(province_no);
        bean.setProvince_name(province_name);
        bean.setCity_no(city_no);
        bean.setCity_name(city_name);
        bean.setAddress(address);
        bean.setApplicant(applicant);
        bean.setPackage_id(PLATFORM_TAG);
        bean.setApp_type("1");

        String object = "Register";
        String action = "Request_Register";
        String jsonStr = getOADJsonStr(bean, object, action);
        byte[] data = getTLVPackaget(jsonStr, false);
        return sendDataToRegisterServer(data, OACMDBaseBean.class);
    }

    /*-----luicien ??-----------*/
    public ResultModel requestRegister(String register_type, String user_name, String mobile, String verify_code,
            String is_verify, String applicant, String province_no, String province_name, String city_no,
            String city_name, String area_no, String area_name, String address) {
        OADRequestRegister bean = new OADRequestRegister();
        bean.setMobile(mobile);
        bean.setVerify_code(verify_code);
        bean.setIs_verify(is_verify);
        bean.setUser_name(user_name);
        bean.setRegister_type(register_type);
        bean.setProvince_no(province_no);
        bean.setProvince_name(province_name);
        bean.setCity_no(city_no);
        bean.setCity_name(city_name);
        bean.setArea_no(area_no);
        bean.setArea_name(area_name);
        bean.setAddress(address);
        bean.setApplicant(applicant);
        bean.setPackage_id(PLATFORM_TAG);
        bean.setApp_type("1");
        String object = "Register";
        String action = "Request_Register";
        String jsonStr = getOADJsonStr(bean, object, action);
        byte[] data = getTLVPackaget(jsonStr, false);
        return sendDataToRegisterServer(data, OACMDBaseBean.class);
    }

    public ResultModel verifyRegister(String register_type, String user_name, String mobile, String verify_code,
            String applicant, String user_password, String province_no, String province_name, String city_no,
            String city_name, String area_no, String area_name, String agent_id, String operator_id, String address,
            String is_verify, String set_password_flag) {
        OADVerifyRegister bean = new OADVerifyRegister();
        bean.setMobile(mobile);
        bean.setUser_name(user_name);
        bean.setRegister_type(register_type);
        bean.setVerify_code(verify_code);
        bean.setApplicant(applicant);
        bean.setUser_password(user_password);

        bean.setProvince_no(province_no);
        bean.setProvince_name(province_name);

        bean.setCity_no(city_no);
        bean.setCity_name(city_name);

        bean.setArea_no(area_no);
        bean.setArea_name(area_name);

        bean.setAgent_id(agent_id);
        bean.setOperator_id(operator_id);
        bean.setAddress(address);
        bean.setIs_verify(is_verify);
        bean.setSet_password_flag(set_password_flag);

        String object = "Register";
        String action = "Verify_Register";
        String jsonStr = getOADJsonStr(bean, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDBaseBean.class);
    }

    // public ResultModel requestVerifyCode(String user_name, String mobile){
    // OADUserBean bean = new OADUserBean();
    // bean.setMobile(mobile);
    // bean.setUser_name(user_name);
    //
    // String object = "Verify";
    // String action = "Request_Verify_Code";
    // String jsonStr = getOADJsonStr(bean, object, action);
    //
    // byte[] data = getTLVPackaget(jsonStr, false);
    //
    // return sendDataToRegisterServer(data, OACMDBaseBean.class);
    // }

    public ResultModel requestVerifyCode(String user_name, String mobile, String is_verify) {
        OADRequestVerifyCode bean = new OADRequestVerifyCode();
        bean.setMobile(mobile);
        bean.setUser_name(user_name);
        bean.setIs_verify(is_verify);

        String object = "Verify";
        String action = "Request_Verify_Code";
        String jsonStr = getOADJsonStr(bean, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDBaseBean.class);
    }

    public ResultModel checkVerifyCode(String user_name, String mobile, String verify_code) {
        OADRequestRegister bean = new OADRequestRegister();
        MyLog.d("checkVerifyCode", user_name + mobile + verify_code);
        bean.setMobile(mobile);
        bean.setVerify_code(verify_code);
        bean.setUser_name(user_name);
        String object = "Verify";
        String action = "Verify_Code";
        String jsonStr = getOADJsonStr(bean, object, action);
        byte[] data = getTLVPackaget(jsonStr, false);
        return sendDataToRegisterServer(data, OACMDBaseBean.class);
    }

    public ResultModel queryBank() {
        String object = "Base_Info";
        String action = "Query_Bank";
        String jsonStr = getOADJsonStr(object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDBankInfo.class);
    }

    public ResultModel queryBranchBank(String bank_name_code, String bank_name, String province_no,
            String province_name, String city_no, String city_name) {
        OADBranchBank bean = new OADBranchBank();
        bean.setBank_name_code(bank_name_code);
        bean.setBank_name(bank_name);
        bean.setProvince_no(province_no);
        bean.setProvince_name(province_name);
        bean.setCity_no(city_no);
        bean.setCity_name(city_name);

        String object = "Base_Info";
        String action = "Query_Branch_Bank";
        String jsonStr = getOADJsonStr(bean, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDBankBranch.class);
    }

    public ResultModel queryType() {
        String object = "Base_Info";
        String action = "Query_Type";
        String jsonStr = getOADJsonStr(object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDTypeInfo.class);
    }

    //add by terence  ??action
    public ResultModel modifyMerchantBaseInfo(OADMerchantBaseInfo info) {
        String object = "Merchant_Base_Info";
        String action = "Modify";

        // ???? ?(0)  Modify_Upgrade_Info
        boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(),
                "0");
        boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance())
                .getBoolean(Constants.FROM_PROMOTE, false);
        //        MyLog.info("Merchant_Base_Info", "isFromPromote=" + isPromote);

        if (isPromote || isVerify) {
            action = "Modify_Upgrade_Info";
        }

        //        MyLog.info("Merchant_Base_Info", action);

        String jsonStr = getOADJsonStr(info, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    //------terence add 2016--07--20 ??
    public ResultModel updateMerchantBaseInfo(OADMerchantBaseInfo info) {
        String object = "Merchant_Base_Info";
        String action = "Modify_Upgrade_Info";
        //MyLog.info("");
        //        MyLog.info("Merchant_Base_Info", action);
        String jsonStr = getOADJsonStr(info, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    public ResultModel o2oUploadPictureInfo(String user_name, String session_id, String merchant_id, TLVBytes tlv) {
        String object = "o2o";
        String action = "upload";
        OADo2oUploadPhotoInfo info = new OADo2oUploadPhotoInfo();
        info.setUser_name(user_name);
        info.setSession_id(session_id);
        info.setMerchant_id(merchant_id);
        info.setBusiness_type("1");
        info.setFile_type("jpeg");
        String jsonStr = getOADJsonStr(info, object, action);

        byte[] data = getTLVPackagetO2O(jsonStr, false, tlv);

        String url = O2O_PROXY + "tlv.do";

        return sendDataToO2OServer(url, data, OACMDo2oUploadPictureBean.class);
    }

    public ResultModel uploadPictureInfo(OADUploadPictureInfo info, TLVBytes tlv) {
        String object = "Picture_Info";
        String action = "Upload";
        // ???? ?(0)  Modify_Upgrade_Info
        boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(),
                "0");
        boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance())
                .getBoolean(Constants.FROM_PROMOTE, false);
        //        MyLog.d("isFromPromote", "isFromPromote=" + isPromote);
        if (isPromote || isVerify) {
            action = "Upload_Upgrade_Pic";
        }
        String jsonStr = getOADJsonStr(info, object, action);

        byte[] data = getTLVPackaget(jsonStr, false, tlv);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    //----------------------------------------------------------------------------------------------

    //------terence add 2016--07--20 ??
    //    public ResultModel updatePictureInfo(OADUploadPictureInfo info, TLVBytes tlv) {
    //        String object = "Picture_Info";
    //        String action = "Upload_Upgrade_Pic";
    //        String jsonStr = getOADJsonStr(info, object, action);
    //
    //        byte[] data = getTLVPackaget(jsonStr, false, tlv);
    //
    //        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    //    }

    //    public ResultModel updatePictureInfo(OADUploadPictureInfo info,
    //                                         TLVBytes tlv1, TLVBytes tlv2) {
    //        String object = "Picture_Info";
    //        String action = "Upload_Upgrade_Pic";
    //        String jsonStr = getOADJsonStr(info, object, action);
    //
    //        byte[] data = getTLVPackaget(jsonStr, false, tlv1, tlv2);
    //
    //        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    //    }
    //
    //    public ResultModel updatePictureInfo(OADUploadPictureInfo info,
    //                                         TLVBytes tlv1, TLVBytes tlv2, TLVBytes tlv3) {
    //        String object = "Picture_Info";
    //        String action = "Upload_Upgrade_Pic";
    //        String jsonStr = getOADJsonStr(info, object, action);
    //
    //        byte[] data = getTLVPackaget(jsonStr, false, tlv1, tlv2, tlv3);
    //
    //        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    //    }
    public ResultModel uploadPictureInfo(OADUploadPictureInfo info, TLVBytes tlv1, TLVBytes tlv2) {
        String object = "Picture_Info";
        String action = "Upload";
        // ???? ?(0)  Modify_Upgrade_Info
        boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(),
                "0");
        boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance())
                .getBoolean(Constants.FROM_PROMOTE, false);
        if (isPromote || isVerify) {
            action = "Upload_Upgrade_Pic";
        }

        String jsonStr = getOADJsonStr(info, object, action);

        byte[] data = getTLVPackaget(jsonStr, false, tlv1, tlv2);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    public ResultModel uploadPictureInfo(OADUploadPictureInfo info, TLVBytes tlv1, TLVBytes tlv2, TLVBytes tlv3) {
        String object = "Picture_Info";
        String action = "Upload";
        // ???? ?(0)  Modify_Upgrade_Info
        boolean isVerify = TextUtils.equals(MyApplication.getInstance().getMachInfoModel().getMerchant_statue(),
                "0");
        boolean isPromote = PreferenceManager.getDefaultSharedPreferences(MyApplication.getInstance())
                .getBoolean(Constants.FROM_PROMOTE, false);
        if (isPromote || isVerify) {
            action = "Upload_Upgrade_Pic";
        }

        String jsonStr = getOADJsonStr(info, object, action);

        byte[] data = getTLVPackaget(jsonStr, false, tlv1, tlv2, tlv3);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    public ResultModel submitExamine(String user_name, String mobile) {

        OADUserBean bean = new OADUserBean();
        bean.setMobile(mobile);
        bean.setUser_name(user_name);

        String object = "Examine_Info";
        String action = "Examine";
        String jsonStr = getOADJsonStr(bean, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDMerchantBaseInfo.class);
    }

    public ResultModel retrievePassword(String user_name, String mobile, String verify_code, String new_passwd) {
        OADRetrievePassword bean = new OADRetrievePassword();
        bean.setMobile(mobile);
        bean.setUser_name(user_name);
        bean.setVerify_code(verify_code);
        bean.setNew_passwd(new_passwd);

        String object = "Retrieve_Password";
        String action = "Retrieve";
        String jsonStr = getOADJsonStr(bean, object, action);

        byte[] data = getTLVPackaget(jsonStr, false);

        return sendDataToRegisterServer(data, OACMDBaseBean.class);
    }

    public ResultModel sendDataToRegisterServer(byte[] data, Class classOfT) {
        String host = REGISTER_HOST; // "192.168.21.243";
        int port = REGISTER_PORT; // 8061;
        InetAddress address;
        try {
            address = InetAddress.getByName(host);
            Socket socket = new Socket(address, port);
            socket.setKeepAlive(true);// ????
            socket.setSoTimeout(60 * 1000);// 
            OutputStream out = socket.getOutputStream();
            out.write(data);
            out.flush();
            InputStream input = socket.getInputStream();
            boolean bGetHead = ServerSocketConnectUtil.getHead(socket,
                    ServerSocketConnectUtil.HEAD_TYPE_REGISTER_SYSTEM);
            if (bGetHead == false) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            byte[] bytes = new byte[4];
            int length = input.read(bytes);
            if (length != 4) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            ByteArrayReader bar = new ByteArrayReader(bytes);
            int dataLength = bar.readIntHighByteFirst(); // readIntHighByteFirst
            // readIntLowByteFirst
            if (dataLength < 0) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }
            bytes = new byte[dataLength];
            length = input.read(bytes);
            while (length < dataLength) {
                length += input.read(bytes, length, dataLength - length);
            }

            if (length != dataLength) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }

            byte[] bytesMsgHeader = new byte[4];
            System.arraycopy(bytes, 0, bytesMsgHeader, 0, 4);
            if (!ServerSocketConnectUtil.checkHead(ServerSocketConnectUtil.HEAD_REGISTER_SYSTEM_HEADER,
                    bytesMsgHeader)) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }

            System.arraycopy(bytes, 4, bytesMsgHeader, 0, 4);
            bar = new ByteArrayReader(bytesMsgHeader);
            length = bar.readIntHighByteFirst();

            int index = 8 + length;
            System.arraycopy(bytes, index, bytesMsgHeader, 0, 4);
            index += 4;
            if (!ServerSocketConnectUtil.checkHead(ServerSocketConnectUtil.HEAD_REGISTER_SYSTEM_BODY,
                    bytesMsgHeader)) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }

            System.arraycopy(bytes, index, bytesMsgHeader, 0, 4);
            index += 4;

            System.arraycopy(bytes, index, bytesMsgHeader, 0, 4);
            index += 4;
            if (!ServerSocketConnectUtil.checkHead(ServerSocketConnectUtil.HEAD_REGISTER_SYSTEM_BODY_CONTENT,
                    bytesMsgHeader)) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }

            System.arraycopy(bytes, index, bytesMsgHeader, 0, 4);
            index += 4;
            bar = new ByteArrayReader(bytesMsgHeader);
            length = bar.readIntHighByteFirst();

            if (dataLength < index + length) {
                return new ResultModel(Device.SYSTEM_FAIL);
            }

            byte[] josnBytes = new byte[length];
            System.arraycopy(bytes, index, josnBytes, 0, length);

            ResultModel resultModel = new ResultModel(josnBytes, classOfT);

            // if (bNeedRecycleRegisterServerSocket) {
            // out.close();
            // input.close();
            // registerServerSocket.close();
            // registerServerSocket = null;
            // }

            return resultModel;
        } catch (UnknownHostException e) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (SocketException e1) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (IOException e2) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        }
    }

    public ResultModel sendDataToO2OServer(String url, byte[] data, Class classOfT) {
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            MyLog.d(TAG, url);
            HttpPost post = null;
            post = new HttpPost(url);
            post.setEntity(new ByteArrayEntity(data));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                //                String strResult = EntityUtils.toString(entity);
                byte[] dataCache = EntityUtils.toByteArray(entity);
                byte[] bytesMsgHeader = new byte[4];
                byte[] jsonBytes = null;

                System.arraycopy(dataCache, 0, bytesMsgHeader, 0, 4);
                if (!ServerSocketConnectUtil.checkHead(ServerSocketConnectUtil.HEAD_REGISTER_SYSTEM,
                        bytesMsgHeader)) {
                    return new ResultModel(Device.SYSTEM_FAIL);
                }

                int length = dataCache.length - 4;
                bytesMsgHeader = new byte[length];
                System.arraycopy(dataCache, 4, bytesMsgHeader, 0, length);
                for (int i = 0; i < length - 4; i++) {
                    byte[] tempB = new byte[4];
                    System.arraycopy(bytesMsgHeader, i, tempB, 0, 4);
                    if (ServerSocketConnectUtil.checkHead(ServerSocketConnectUtil.HEAD_REGISTER_SYSTEM_BODY_CONTENT,
                            tempB)) {
                        jsonBytes = new byte[length - i - 8];
                        System.arraycopy(bytesMsgHeader, i + 8, jsonBytes, 0, (length - i - 8));
                        //                        System.out.println("jsonBytes = " + jsonBytes.toString());
                        break;
                    }
                }
                if (jsonBytes != null) {
                    //                    System.out.println("jsonBytes ?? ");
                    ResultModel resultModel = new ResultModel(jsonBytes, classOfT);
                    return resultModel;
                } else {
                    //                    System.out.println("jsonBytes ? ");
                    return new ResultModel(Device.TRANSACTION_NET_FAIL);
                }
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel registerUser(String strMachId, String strTerminalId, String strAdminName,
            String strAdminPassword, String strOperatorName, String strOperatorPassword) {
        byte[] head = Device.nativeFunction2229(device);
        byte[] body = Device.nativeFunction2239(device, strMachId, strTerminalId, strAdminName, strAdminPassword,
                strOperatorName, strOperatorPassword);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel unregisterUser(String strMachId, String strTerminalId, String strAdminName,
            String strAdminPassword, String strOperatorName) {
        byte[] head = Device.nativeFunction2230(device);
        byte[] body = Device.nativeFunction2240(device, strMachId, strTerminalId, strAdminName, strAdminPassword,
                strOperatorName);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel changePassword(String strOldPassword, String strNewPassword) {
        byte[] head = Device.nativeFunction1004(device);
        byte[] body = Device.nativeFunction1005(device, strOldPassword, strNewPassword);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel sendSignPic(String merchantID, String strPayOrderId, String cardSignData) {
        byte[] head = Device.nativeFunction2026(device);
        byte[] body = Device.nativeFunction2013(device, merchantID, strPayOrderId, cardSignData);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel sendPhotoPicByMail(String merchantID, String strPayOrderID, String strEmailAddress) {
        byte[] head = Device.nativeFunction2014(device);
        byte[] body = Device.nativeFunction2015(device, merchantID, strPayOrderID, strEmailAddress);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel getMachOrderId(Integer nAmount) {
        byte[] head = Device.nativeFunction2004(device);
        byte[] body = Device.nativeFunction2005(device, nAmount);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel getWinddorKTVOrderId(Integer nAmount, String strGoodsType, String strGoodsName,
            String strGoodsDetail) {
        byte[] head = Device.nativeFunction2030(device);
        byte[] body = Device.nativeFunction2031(device, nAmount, strGoodsType, strGoodsName, strGoodsDetail);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel getThirdMachOrderId(Integer nAmount, String strThirdOrderID) {
        byte[] head = Device.nativeFunction2004(device);
        byte[] body = Device.nativeFunction2029(device, nAmount, strThirdOrderID, "");

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    // public ResultModel couponAdd(String session_id, String merchant_id,
    // String username, String title, String sub_title, String dis_title,
    // String desc, String merchant_name, String merchant_address, String
    // merchant_mobile, String logo, String ibeacon_id) {
    // List<NameValuePair> params = new ArrayList<NameValuePair>();
    // params.add(new BasicNameValuePair("session_id", session_id));
    // params.add(new BasicNameValuePair("merchant_id", merchant_id));
    // params.add(new BasicNameValuePair("uin", username));
    // params.add(new BasicNameValuePair("title", title));
    // params.add(new BasicNameValuePair("sub_title", sub_title));
    // params.add(new BasicNameValuePair("dis_title", dis_title));
    // params.add(new BasicNameValuePair("desc", desc));
    // params.add(new BasicNameValuePair("merchant_name", merchant_name));
    // params.add(new BasicNameValuePair("merchant_address", merchant_address));
    // params.add(new BasicNameValuePair("merchant_mobile", merchant_mobile));
    // params.add(new BasicNameValuePair("ibeacon_id", ibeacon_id));
    // params.add(new BasicNameValuePair("logo", logo));
    // return postUrlGetDataToServerReturnData(COUPON_SERVER_ADD_CGI, params);
    // }
    //
    // public ResultModel couponEdit(String coupon_id, String session_id, String
    // merchant_id, String username, String title, String sub_title, String
    // dis_title,
    // String desc, String merchant_name, String merchant_address, String
    // merchant_mobile, String logo, String ibeacon_id) {
    // List<NameValuePair> params = new ArrayList<NameValuePair>();
    // params.add(new BasicNameValuePair("coupon_id", coupon_id));
    // params.add(new BasicNameValuePair("session_id", session_id));
    // params.add(new BasicNameValuePair("merchant_id", merchant_id));
    // params.add(new BasicNameValuePair("uin", username));
    // params.add(new BasicNameValuePair("title", title));
    // params.add(new BasicNameValuePair("sub_title", sub_title));
    // params.add(new BasicNameValuePair("dis_title", dis_title));
    // params.add(new BasicNameValuePair("desc", desc));
    // params.add(new BasicNameValuePair("merchant_name", merchant_name));
    // params.add(new BasicNameValuePair("merchant_address", merchant_address));
    // params.add(new BasicNameValuePair("merchant_mobile", merchant_mobile));
    // params.add(new BasicNameValuePair("ibeacon_id", ibeacon_id));
    // params.add(new BasicNameValuePair("logo", logo));
    // return postUrlGetDataToServerReturnData(COUPON_SERVER_EDIT_CGI, params);
    // }
    //
    // public ResultModel couponInfo(String session_id, String merchant_id,
    // String username) {
    // List<NameValuePair> params = new ArrayList<NameValuePair>();
    // params.add(new BasicNameValuePair("session_id", session_id));
    // params.add(new BasicNameValuePair("merchant_id", merchant_id));
    // params.add(new BasicNameValuePair("uin", username));
    // return postUrlGetDataToServerReturnData(COUPON_SERVER_INFO_CGI, params);
    // }

    public ResultModel queryAlipayTipDialogShowStatue(String userName, String pwd) {
        String url = QUERY_ALIPAY_TIP_DILOAG_SHOW_STATUE_SERVER_CGI + "?uuid=" + URLEncoder.encode(userName)
                + "&pwd=" + URLEncoder.encode(pwd);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryTuituiMsgCount(String userName, String pwd) {
        String url = QUERY_TUITUI_MSG_COUNT_SERVER_CGI + "?uuid=" + URLEncoder.encode(userName) + "&pwd="
                + URLEncoder.encode(pwd);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryO2OOrderCount(String merchantId, String userName, String sessionId) {
        String url = QUERY_O2O_ORDER_COUNT_SERVER_CGI + "?username=" + URLEncoder.encode(userName) + "&session_id="
                + URLEncoder.encode(sessionId) + "&merchant_id=" + URLEncoder.encode(merchantId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryO2OPrintOrderInfo(String merchantUid, String deal_id) {
        String url = QUERY_O2O_ORDER_INFO_SERVER_CGI + "?dis_dealid=" + URLEncoder.encode(deal_id) + "&merchantUid="
                + URLEncoder.encode(merchantUid);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel tuituiCancleWechatShare(String userName, String pwd) {
        String url = TUITUI_CANCLE_WECHAT_SHARE_SERVER_CGI + "?uuid=" + URLEncoder.encode(userName) + "&pwd="
                + URLEncoder.encode(pwd);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardTransBankList(String version) {
        String url = CARD_TRANS_INFO_SERVER_CGI + "?s=leshua.app.transfer&cmd=query_banks&ver=" + version;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardTransAllData() {
        String url = CARD_TRANS_INFO_SERVER_CGI + "?s=leshua.app.transfer&cmd=query_all";
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardTransBankBranchInfo(String bid) {
        String url = CARD_TRANS_INFO_SERVER_CGI + "?s=leshua.app.transfer&cmd=query_branch&bid=" + bid;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardTransBankSpecificBankBranchInfo(String bv) {
        String url = CARD_TRANS_INFO_SERVER_CGI + "?s=leshua.app.transfer&cmd=query_bank_branch&bv=" + bv;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardTransBankSettleTimeInfo() {
        String url = CARD_TRANS_INFO_SERVER_CGI + "?s=leshua.app.transfer&cmd=query_bank_settle_time";
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel querySpecificCardTransBankOrderInfo(String orderId) {
        String url = CARD_TRANS_ORDER_QEURY_SERVER_CGI + "?s=ykpay.app.transfer&cmd=query_order&order_id="
                + URLEncoder.encode(orderId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel oldQuerySpecificCardTransBankOrderInfo(String orderId) {
        String url = OLD_CARD_TRANS_ORDER_QEURY_SERVER_CGI + "?s=leshua.app.transfer&cmd=query_order&order_id="
                + URLEncoder.encode(orderId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryMonitorInfo(String session_id, String merchant_id, String uin, String begin,
            String end) {
        String url = WISDOM_MALL_SERVER_CGI + "getMonitorInfo.do?session_id=" + URLEncoder.encode(session_id)
                + "&merchant_id=" + URLEncoder.encode(merchant_id) + "&uin=" + URLEncoder.encode(uin) + "&begin="
                + URLEncoder.encode(begin) + "&end=" + URLEncoder.encode(end);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardConsumeList(String session_id, String merchant_id, String uin, String page,
            String page_size, String condition_text, String begin, String end) {
        String url = WISDOM_MALL_SERVER_CGI + "getCardConsumeList.do?session_id=" + URLEncoder.encode(session_id)
                + "&merchant_id=" + URLEncoder.encode(merchant_id) + "&uin=" + URLEncoder.encode(uin) + "&page="
                + URLEncoder.encode(page) + "&page_size=" + URLEncoder.encode(page_size) + "&condition_text="
                + URLEncoder.encode(condition_text) + "&begin=" + URLEncoder.encode(begin) + "&end="
                + URLEncoder.encode(end);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel logoutCard(String session_id, String merchant_id, String uin, String card_seri) {
        String url = WISDOM_MALL_SERVER_CGI + "logoutCard.do?session_id=" + URLEncoder.encode(session_id)
                + "&merchant_id=" + URLEncoder.encode(merchant_id) + "&uin=" + URLEncoder.encode(uin)
                + "&card_seri=" + URLEncoder.encode(card_seri);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryMerchantRemainSmsCount(String strMerchantId) {
        String url = SMS_STORE_SERVER_CGI + "getSMSBalance.do?FMerchantId=" + URLEncoder.encode(strMerchantId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel querySmsStoreChargePackegeInfo() {
        String url = SMS_STORE_SERVER_CGI + "getSMSPackages.do";
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel querySmsStoreSmsTemplateInfo() {
        String url = SMS_STORE_SERVER_CGI + "getSMSTemplate.do";
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel createSmsStoreOrder(String strMerchantId, String smsPackagesId) {
        String url = SMS_STORE_SERVER_CGI + "getSMSOrders.do?FMerchantId=" + URLEncoder.encode(strMerchantId)
                + "&packagesId=" + URLEncoder.encode(smsPackagesId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel sendSmsStoreSms(String strMerchantId, String numberList, String strSmsText) {
        String url = SMS_STORE_SERVER_CGI + "sendSMS.do?FMerchantId=" + URLEncoder.encode(strMerchantId)
                + "&number=" + URLEncoder.encode(numberList) + "&txt=" + URLEncoder.encode(strSmsText);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryCardTransBankOrderListInfo(String userName, String start_time, Integer count) {
        String url = CARD_TRANS_ORDER_QEURY_SERVER_CGI + "?s=ykpay.app.transfer&cmd=query_order_list&count=" + count
                + "&time=" + URLEncoder.encode(start_time) + "&name=" + userName;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryOldCardTransBankOrderListInfo(String userName, String start_time, Integer count) {
        String url = OLD_CARD_TRANS_ORDER_QEURY_SERVER_CGI + "?s=leshua.plat&cmd=query_transfer_orders&count="
                + count + "&start_time=" + URLEncoder.encode(start_time) + "&name=" + userName;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel checkMachCanUseMicrofinance(String userName, String userPwd) {
        String url = MICROFINANCE_CHECK_CITY_SERVER_CGI + "?username=" + URLEncoder.encode(userName) + "&userpwd="
                + URLEncoder.encode(userPwd);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel checkMachHaveAdHis(String userName, String userPwd) {
        String url = MACH_CHECK_AD_HIS_SERVER_CGI + "?username=" + URLEncoder.encode(userName) + "&userpwd="
                + URLEncoder.encode(userPwd);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel updateSelectConnectType(String userName, String merchantId, String applicationType) {
        String inputString = "www.yeahka.com" + userName + merchantId;
        String md5 = Util.createInputStringMd5SignUpperCase(inputString);
        if (md5 == null || md5.equals("")) {
            return new ResultModel(-999);
        }
        String url = UPDATE_SELECT_CONNCET_TYPE_CGI + "?userName=" + URLEncoder.encode(userName) + "&FMerchantId="
                + URLEncoder.encode(merchantId) + "&apptype=" + APP_TYPE + "&applicationType="
                + URLEncoder.encode(applicationType) + "&sign=" + URLEncoder.encode(md5);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel getWechatOpenFeeInfo(String userName, String userPwd) {
        String url = WECHAT_PAY_WEB_GET_FEE_RATE_SERVER_CGI + "?username=" + URLEncoder.encode(userName)
                + "&userpwd=" + URLEncoder.encode(userPwd);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel createWechatOpenOrder(String userName, String userPwd, String amount, String merchantId) {
        String url = WECHAT_PAY_WEB_CREATE_ORDER_SERVER_CGI + "?username=" + URLEncoder.encode(userName)
                + "&userpwd=" + URLEncoder.encode(userPwd) + "&amount=" + URLEncoder.encode(amount)
                + "&FMerchantId=" + URLEncoder.encode(merchantId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel getUserLoginContentAd() {
        String url = USER_LOGIN_AD_URL;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryUserOpenReadCardAdStatue(String userName) {
        String url = USER_OPEN_READ_CARD_URL + "?FUserName=" + URLEncoder.encode(userName);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel updateWechatGoodsType(String userName, String userPwd, String merchantId,
            String fCategoryId) {
        String url = UPDATE_WECHAT_GOODS_TYPE_CGI + "?uuid=" + URLEncoder.encode(userName) + "&pwd="
                + URLEncoder.encode(userPwd) + "&matchid=" + URLEncoder.encode(merchantId) + "&fCategoryId="
                + URLEncoder.encode(fCategoryId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryO2OShopInfo(String merchant_id, String username, String session_id) {
        String url = MachInfoWebViewActivity.LEPOS_O2O_HOME_URL + "?merchant_id=" + URLEncoder.encode(merchant_id)
                + "&username=" + URLEncoder.encode(username) + "&session_id=" + URLEncoder.encode(session_id)
                + "&url=get_shop_info";
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel GetTuiTuiUpdateInfo(String merchant_id, String username, String session_id) {
        String url = QUERY_TUITUI_TEXT_UPDATE_SERVER_CGI + "?merchant_id=" + URLEncoder.encode(merchant_id)
                + "&username=" + URLEncoder.encode(username) + "&session_id=" + URLEncoder.encode(session_id);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel queryO2OAdInfo(String merchant_id, String username, String session_id) {
        String url = MachInfoWebViewActivity.LEPOS_O2O_HOME_URL + "?merchant_id=" + URLEncoder.encode(merchant_id)
                + "&username=" + URLEncoder.encode(username) + "&session_id=" + URLEncoder.encode(session_id)
                + "&url=get_ad_info";
        return sendUrlGetDataToServerReturnData(url);
    }

    /*
     * 0  -- ? -1  -- ?? -2 ? --
    *  -3  --  -4 ? -- ????
    */
    public ResultModel ledCheckOpen(String merchantId) {
        String url = MachInfoWebViewActivity.LED_CHECK_OPEN + "?merchant_id=" + URLEncoder.encode(merchantId);
        // System.out.println("ledCheckOpen url = " + url);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel ledCheckMerchantPic(String merchantId) {
        String url = MachInfoWebViewActivity.LED_CHECK_MERCHANT_PIC + "?merchant_id="
                + URLEncoder.encode(merchantId);
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel bindO2OUserOrderInfo(String merchant_id, String session_id, String app_id, String user_id,
            String channel_id) {
        String url = BIND_O2O_USER_ORDER_INFO + "?merchant_id=" + URLEncoder.encode(merchant_id) + "&session_id="
                + URLEncoder.encode(session_id) + "&app_id=" + URLEncoder.encode(app_id) + "&user_id="
                + URLEncoder.encode(user_id) + "&channel_id=" + URLEncoder.encode(channel_id) + "&app_type="
                + APP_TYPE + "&app_version=" + DEVICE_VERSION;
        return sendUrlGetDataToServerReturnData(url);
    }

    public ResultModel upLoadLedRunTimeAndCount(String userName, String sessionId, String merchantId,
            String ad_deliver_time, String runtime, String lb305_id, String jsonInfo) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_UPLOAD_AD_PLAY_COUNT_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                merchantId + "|" + ad_deliver_time + "|" + runtime + "|" + lb305_id + "|" + jsonInfo, true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel upLoadLedRunTimeAndCountAdSys(String merchantId, String sn, String timePacket,
            String countPacket1, String countPacket2, String countPacket3, String jsonsStr) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_UPLOAD_AD_SYS_PLAY_COUNT_COMMAND);
        String requestStr = merchantId + "|" + sn + "|" + timePacket + "|" + countPacket1 + "|" + countPacket2 + "|"
                + countPacket3 + "|" + jsonsStr;
        byte[] data = Device.nativeFunction10001(device, requestStr, true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    // 6. ?????
    // Cmd=15,userid=$str,session_id=$str,merchant=$str,lb305_id=$str,swich_flag=$str(
    // 0 11???31?131??11?)
    // Err_code=$n,error_msg=$str,error_tip=$str, packet_data=$str(??)
    public ResultModel queryLedSwitchAdPositionPacket(String userName, String sessionId, String merchantId,
            String sn, String switchFlag) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_LED_SWITCH_AD_POSITION_COMMAND);
        String requestStr = userName + "|" + sessionId + "|" + merchantId + "|" + sn + "|" + switchFlag;
        byte[] data = nativeFunction10011(device, requestStr);
        return sendCommandPackageToLedServerAndReturnResultModel(command, data);
    }

    // Cmd=14,userid=$str,session_id=$str,merchant=$str,switch_on=$str(0???1??),
    // lb305_id=$str
    // Err_code=$n,error_msg=$str,error_tip=$str, packet_data=$str(??)
    public ResultModel queryLedSwitchSignPacket(String userName, String sessionId, String merchantId,
            String switchOn, String sn) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_LED_SWITCH_PACKET_COMMAND);
        String requestStr = userName + "|" + sessionId + "|" + merchantId + "|" + switchOn + "|" + sn;
        byte[] data = nativeFunction10011(device, requestStr);
        return sendCommandPackageToLedServerAndReturnResultModel(command, data);
    }

    public ResultModel queryLedData(String userName, String sessionId, String merchantId) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_LED_AD_LIST_COMMAND);
        byte[] data = nativeFunction10011(device, userName + "|" + sessionId + "|" + merchantId);
        return sendCommandPackageToLedServerAndReturnResultModel(command, data);
    }

    public ResultModel queryLedData(String userName, String sessionId, String merchantId, String sn,
            String switchFlag, String newDataFlag) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_LED_AD_LIST_COMMAND);
        byte[] data = nativeFunction10011(device, userName + "|" + sessionId + "|" + merchantId + "|" + sn + "|"
                + switchFlag + "|" + newDataFlag + "|1");
        return sendCommandPackageToLedServerAndReturnResultModel(command, data);
    }

    public ResultModel queryLedStatisticsData(String merchantId) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_LED_STATISTICS_DATA_COMMAND);
        byte[] data = nativeFunction10011(device, merchantId);
        return sendCommandPackageToLedServerAndReturnResultModel(command, data);
    }

    public ResultModel addLedAd(String userName, String sessionId, String merchantId, String ad_text) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_SUB_ADD_AD_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchantId + "|" + ad_text, true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel addLedAd(String userName, String sessionId, String merchantId, String ad_text, String sn,
            String switchFlag) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_SUB_ADD_AD_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                merchantId + "|" + ad_text + "|" + sn + "|" + switchFlag + "|1", true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel modifyLedAd(String userName, String sessionId, String merchantId, String ad_id,
            String ad_from, String ad_statue, String ad_text) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_SUB_MODIFY_AD_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                merchantId + "|" + ad_id + "|" + ad_from + "|" + ad_statue + "|" + ad_text, true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel modifyLedAd(String userName, String sessionId, String merchantId, String ad_id,
            String ad_from, String ad_statue, String ad_text, String sn, String switchFlag) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_SUB_MODIFY_AD_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchantId + "|" + ad_id + "|" + ad_from + "|" + ad_statue
                + "|" + ad_text + "|" + sn + "|" + switchFlag + "|1", true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel queryBindLedDeviceList(String userName, String sessionId, String merchantId) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_LED_DEVICE_LIST_COMMAND);
        byte[] data = nativeFunction10011(device, userName + "|" + sessionId + "|" + merchantId);
        return sendCommandPackageToLedServerAndReturnResultModel(command, data);
    }

    public ResultModel machBindLedDevice(String userName, String sessionId, String merchantId, String lb305_id) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_SUB_BIND_OR_UNBIND_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchantId + "|" + lb305_id + "|1", true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel machUnbindLedDevice(String userName, String sessionId, String merchantId, String lb305_id) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SECURITY_SUB_BIND_OR_UNBIND_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchantId + "|" + lb305_id + "|0", true);
        return sendSecurityPackageToLedServerAndReturnResultModel(command, Device.nativeFunction66(device), data);
    }

    public ResultModel hongbaoQueryHongbaoList(String userName, String sessionId, String merchantId,
            String IbeaconType, String sn) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_HONGBAO_LIST_COMMAND);
        byte[] data = nativeFunction10011(device,
                userName + "|" + sessionId + "|" + merchantId + "|" + IbeaconType + "|" + sn);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel hongbaoQueryBindIbeaconDeviceList(String userName, String sessionId, String merchantId,
            String IbeaconType) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_HONGBAO_IBEACON_DEVICE_LIST_COMMAND);
        byte[] data = nativeFunction10011(device,
                userName + "|" + sessionId + "|" + merchantId + "|" + IbeaconType);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel hongbaoQuerySendRecord(String userName, String sessionId, String merchantId,
            String Envelop) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_HONGBAO_SEND_RECORD_LIST_COMMAND);
        byte[] data = nativeFunction10011(device, userName + "|" + sessionId + "|" + merchantId + "|" + Envelop);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel hongbaoQueryHongbaoStatisticsTotal(String userName, String sessionId, String merchantId) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_HONGBAO_STATISTICS_TOTAL_COMMAND);
        byte[] data = nativeFunction10011(device, userName + "|" + sessionId + "|" + merchantId);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel queryMachWechatShakeStatue(String merchantId) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_WECHAT_SHAKE_STATUE_COMMAND);
        byte[] data = nativeFunction10011(device, merchantId);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel uploadMachWechatShakeInfo(String merchantId, String mainTitle, String subTitle,
            String diyShopUrl, String picData) {
        byte[] command = Device.nativeFunction10010(device, YKPAYSERVICE_UPLOAD_WECHAT_SHAKE_INFO_COMMAND);
        byte[] data = Device.nativeFunction10011(device,
                merchantId + "|" + mainTitle + "|" + subTitle + "|" + diyShopUrl + "|" + picData);
        return postCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel wechatShakeOpen(String sn, String ibeaconType, String merchantId) {
        byte[] command = Device.nativeFunction10010(device, YKPAYSERVICE_WECHAT_SHAKE_OPEN_COMMAND);
        byte[] data = Device.nativeFunction10011(device, sn + "|" + ibeaconType + "|" + merchantId);
        return postCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel wechatShakeQueryH5PageInfo(String merchantId, String H5type) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_WECHAT_SHAKE_H5_PAGE_INFO_COMMAND);
        byte[] data = nativeFunction10011(device, merchantId + "|" + H5type);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    public ResultModel queryH5PagesList(String merchantId, String sn, String ibeaconType) {
        byte[] command = nativeFunction10010(device, YKPAYSERVICE_QUERY_H5PAGES_INFO_BY_IBEACON_COMMAND);
        byte[] data = nativeFunction10011(device, merchantId + "|" + sn + "|" + ibeaconType);
        return sendCommandPackageToHongbaoServerAndReturnResultModel(command, data);
    }

    // 
    public ResultModel wechatShakeUploadH5PageInfo(String merchantId, String PageId, String H5type,
            String mainTitle, String subTitle, String ContentJson, String picData, String Op, String ibeaconsJson) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_UPLOAD_WECHAT_SHAKE_H5_PAGE_INFO_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchantId + "|" + PageId + "|" + H5type + "|" + mainTitle
                + "|" + subTitle + "|" + ContentJson + "|" + picData + "|" + Op + "|" + ibeaconsJson, true);
        return postSecurityPackageToHongbaoServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel hongbaoModifyIbeaconBindHongbaoList(String userName, String sessionId, String merchantId,
            String sn, String ibeaconType, String operation, String envelopsJson) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_HONGBAO_MODIFY_IBEACON_BIND_HONGBAO_LIST_COMMAND);
        byte[] data = Device.nativeFunction10001(device, userName + "|" + sessionId + "|" + merchantId + "|" + sn
                + "|" + ibeaconType + "|" + operation + "|" + envelopsJson, true);
        return postSecurityPackageToHongbaoServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel hongbaoModifyHongbaoStatus(String userName, String sessionId, String merchantId,
            String Envelop, String operation, String ibeaconsJson) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_HONGBAO_MODIFY_HONGBAO_STATUS_COMMAND);
        byte[] data = Device.nativeFunction10001(device, userName + "|" + sessionId + "|" + merchantId + "|"
                + Envelop + "|" + operation + "|" + ibeaconsJson, true);
        return postSecurityPackageToHongbaoServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel hongbaoAddHongbao(String userName, String sessionId, String merchantId, String EnvelopName,
            String Desc, String tel, String amount, String validTimeBegin, String validTimeEnd, String custLimit,
            String totalCount, String ibeaconsJson) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_HONGBAO_ADD_HONGBAO_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                userName + "|" + sessionId + "|" + merchantId + "|" + EnvelopName + "|" + Desc + "|" + tel + "|"
                        + amount + "|" + validTimeBegin + "|" + validTimeEnd + "|" + custLimit + "|" + totalCount
                        + "|" + ibeaconsJson,
                true);
        return postSecurityPackageToHongbaoServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel hongbaoBindIbeaconDevice(String sessionId, String merchantId, String Opera, String Nickname,
            String IBeaconType, String sn) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_HONGBAO_BIND_OR_UNBIND_IBEACON_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                sessionId + "|" + merchantId + "|" + Opera + "|" + Nickname + "|1" + "|" + IBeaconType + "|" + sn,
                true);
        return sendSecurityPackageToHongbaoServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel operateIbeaconH5Pages(String merchantId, String op, String sn, String ibeaconType,
            String pageIds) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_OPERATE_IBEACON_H5_PAGES_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                merchantId + "|" + op + "|" + sn + "|" + ibeaconType + "|" + pageIds, true);
        return sendSecurityPackageToHongbaoServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel bindGprsPrinter(String merchant_id, String print_machine_sn) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_BIND_GPRS_PRINTER_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchant_id + "|" + print_machine_sn, true);
        return sendSecurityPackageToGprsPrintServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel verifyGprsPrinter(String merchant_id, String print_machine_sn, String verify_code) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_VERIFY_GPRS_PRINTER_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchant_id + "|" + print_machine_sn + "|" + verify_code,
                true);
        return sendSecurityPackageToGprsPrintServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel unBindGprsPrinter(String merchant_id, String print_machine_sn) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_UNBIND_GPRS_PRINTER_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchant_id + "|" + print_machine_sn, true);
        return sendSecurityPackageToGprsPrintServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel queryBindGprsPrinterList(String merchant_id) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_GET_BIND_GPRS_PRINTER_LIST_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchant_id, true);
        return sendSecurityPackageToGprsPrintServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel setGprsPrinter(String merchant_id, String auto_print) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_SET_GPRS_PRINTER_COMMAND);
        byte[] data = Device.nativeFunction10001(device, merchant_id + "|" + auto_print, true);
        return sendSecurityPackageToGprsPrintServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    public ResultModel gprsPrintDeal(String merchant_id, String merchant_uid, String deal_id, String pages) {
        byte[] command = Device.nativeFunction10000(device, SECURITY_COMMAND,
                YKPAYSERVICE_GPRS_PRINTER_PRINT_DEAL_COMMAND);
        byte[] data = Device.nativeFunction10001(device,
                merchant_id + "|" + merchant_uid + "|" + deal_id + "|" + pages, true);
        return sendSecurityPackageToGprsPrintServerAndReturnResultModel(command, Device.nativeFunction66(device),
                data);
    }

    private ResultModel postSecurityPackageToHongbaoServerAndReturnResultModel(byte[] head, int nPackage,
            byte[] data) {
        return postDataToServer(HONGBAO_SERVER_PROXY, head, intToFourByte(nPackage), data);
    }

    private ResultModel postCommandPackageToHongbaoServerAndReturnResultModel(byte[] command, byte[] data) {
        byte[] padding = new byte[1];
        return postDataToServer(HONGBAO_SERVER_PROXY, command, intToFourByte(data.length), data, padding);
    }

    private ResultModel postDataToServer(int proxy, byte[] data1, byte[] data2, byte[] data3) {
        byte[] sendData = Device.nativeFunction60(device, data1, data2, data3);
        return postRawDataToServer(proxy, sendData);
    }

    private ResultModel postDataToServer(int proxy, byte[] data1, byte[] data2, byte[] data3, byte[] data4) {
        byte[] sendData = Device.nativeFunction61(device, data1, data2, data3, data4);
        return postRawDataToServer(proxy, sendData);
    }

    private ResultModel postRawDataToServer(int proxy, byte[] data) {
        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, 20 * 1000);
        HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        String url = "";
        if (proxy == HONGBAO_SERVER_PROXY) {
            url = HONGBAO_SERVER_CGI;
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        } else {
            return new ResultModel("");
        }
        if (MyActivity.SERVER_FAIL) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return new ResultModel("");
        }

        try {
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            MyLog.d(TAG, url);
            HttpPost post = new HttpPost(url);
            String xmlString = "p=" + URLEncoder.encode(Base64.encode(data, 0, data.length));
            post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            // List<NameValuePair> params = new ArrayList<NameValuePair>();
            // params.add(new BasicNameValuePair("p",
            // URLEncoder.encode(Base64.encode(data, 0, data.length))));
            // post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(Base64.decode(new String(sb))));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel queryUserPushInfo() {
        return sendCommandPackageToTransactionServerAndReturnResultModel(Device.nativeFunction2020(device),
                Device.nativeFunction2021(device));
    }

    public ResultModel getCommunicationPara() {
        byte[] head = Device.nativeFunction2016(device);
        byte[] body = Device.nativeFunction2017(device, android.os.Build.MODEL, strLocalDeviceId);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel getShareLoginToken(String strPartnerId, String strUserName, String strUserPassword) {
        byte[] head = Device.nativeFunction1027(device);
        byte[] body = Device.nativeFunction1028(device, strPartnerId, strUserName, strUserPassword);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel authShareLoginToken(String strUserName, String strMachId, String strPartnerId,
            String strToken, String strTimestamp, String strTokenSign, String strPayAmount, String strClientOrderId,
            String strClientContent) {
        byte[] head = Device.nativeFunction1029(device);
        byte[] body = Device.nativeFunction1030(device, strUserName, strMachId, strPartnerId, strToken,
                strTimestamp, strTokenSign, strPayAmount, strClientOrderId, strClientContent);

        return sendSecurityPackageToTransactionServerAndReturnResultModel(head, Device.nativeFunction66(device),
                body);
    }

    public ResultModel queryMachSettledData(String strSettlementMonth) {
        byte[] head = Device.nativeFunction2018(device);
        byte[] body = Device.nativeFunction2019(device, strSettlementMonth);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel getMachInfo() {
        byte[] head = Device.nativeFunction2006(device);
        byte[] body = Device.nativeFunction2007(device);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    public ResultModel getPinPadInfoByPinpadIds(String strMerchantID, String strPinPadList) {
        byte[] head = Device.nativeFunction2027(device);
        byte[] body = Device.nativeFunction2028(device, strMerchantID, strPinPadList);

        return sendCommandPackageToTransactionServerAndReturnResultModel(head, body);
    }

    /**
     * ??SN??SNSN0000000000
     *
     * @param led_iseq
     * @return
     * @author "Char"
     * @create_date 2015-8-28
     */
    public ResultModel queryO2OLed(String led_iseq) {
        StringBuffer url = new StringBuffer();
        url.append(QUERY_O2O_LED).append("?cmd=query_ledseq_info&led_iseq=").append(led_iseq);
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    private ResultModel sendRawDataToServer(int proxy, byte[] data) {
        StringBuilder builder = new StringBuilder();
        HttpParams httpParameters = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(httpParameters, 20 * 1000);
        HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        if (proxy == LOGIN_SERVER_PROXY) {
            builder.append(LOGIN_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 20 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        } else if (proxy == TRANSACTION_SERVER_PROXY) {
            builder.append(TRANSACTION_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 40 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        } else if (proxy == LED_SERVER_PROXY) {
            builder.append(LED_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 40 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        } else if (proxy == HONGBAO_SERVER_PROXY) {
            builder.append(HONGBAO_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 40 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        } else if (proxy == GPRS_PRINTER_SERVER_PROXY) {
            builder.append(GPRS_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 40 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        }
        // =====Char add 2015-07-16 for realname pay
        else if (proxy == REALNAME_PAYMENT_PROXY) {
            builder.append(TRANSACTION_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 40 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        }
        // =====
        // =====Char add 2015-09-09 for quickenloans pay
        else if (proxy == QUICKEN_LOANS_PROXY) {
            builder.append(TRANSACTION_SERVER_CGI);
            HttpConnectionParams.setConnectionTimeout(httpParameters, 40 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        }
        // =====
        else {
            return new ResultModel("");
        }
        if (MyActivity.SERVER_FAIL) {
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return new ResultModel("");
        }

        if (proxy == LOGIN_SERVER_PROXY || proxy == TRANSACTION_SERVER_PROXY || proxy == LED_SERVER_PROXY
                || proxy == HONGBAO_SERVER_PROXY || proxy == REALNAME_PAYMENT_PROXY
                || proxy == QUICKEN_LOANS_PROXY) {
            builder.append("?p=");
            builder.append(URLEncoder.encode(Base64.encode(data, 0, data.length)));
        } else if (proxy == GPRS_PRINTER_SERVER_PROXY) {
            builder.append("?printserver=");
            builder.append(URLEncoder.encode(Base64.encode(data, 0, data.length)));
        } else {
            builder.append("?");
            builder.append(new String(data));
            //            MyActivity.log.info("queryurl", builder.toString());
        }
        //        HttpClient client = new DefaultHttpClient(httpParameters);
        HttpClient client = MyHttps.getNewHttpClient(httpParameters);
        MyLog.d(TAG, builder.toString());
        HttpGet get = new HttpGet(builder.toString());

        if (!isWifiEnabled) {
            String strProxyHost = android.net.Proxy.getDefaultHost();
            if (strProxyHost != null && strProxyHost.length() > 0) {
                int nPort = android.net.Proxy.getDefaultPort();
                get.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
            }
        }

        HttpResponse response;
        try {
            response = client.execute(get);
            StringBuffer sb = new StringBuffer();
            if (response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
                InputStream is = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                String line = null;
                while (true) {
                    line = reader.readLine();
                    if (line == null) {
                        break;
                    } else {
                        sb.append(line);
                    }
                }
                reader.close();
                is.close();
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            if (proxy == LOGIN_SERVER_PROXY) {
                return new ResultModel(Base64.decode(new String(sb)), 0);
            } else if (proxy == TRANSACTION_SERVER_PROXY || proxy == LED_SERVER_PROXY
                    || proxy == HONGBAO_SERVER_PROXY || proxy == GPRS_PRINTER_SERVER_PROXY
                    || proxy == REALNAME_PAYMENT_PROXY || proxy == QUICKEN_LOANS_PROXY) {
                //                MyLog.info("Device", "response=" + new String(sb));
                MyLog.d(TAG, "response=" + new String(Base64.decode(new String(sb))));
                return new ResultModel(new String(Base64.decode(new String(sb))));
            } else if (proxy == LESHUA_TRANSACTION_SERVER_PROXY) {
                return new ResultModel(Base64.decode(new String(sb)));
            } else {
                return new ResultModel(new String(sb));
            }
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {// Base64 exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel sendTransactionSign(String merchantID, String payOrderID, String strCardHolderSign) {
        //        MyLog.info("OrderCenter", "merchantId=" + merchantID + "payOrderId=" + payOrderID + "sign=" + strCardHolderSign);
        byte[] head = Device.nativeFunction2026(device);
        byte[] body = Device.nativeFunction2013(device, merchantID, payOrderID, strCardHolderSign);
        byte[] padding = new byte[1];
        byte[] sendData = Device.nativeFunction61(device, head, intToFourByte(body.length), body, padding);
        String xmlString = "p=" + URLEncoder.encode(Base64.encode(sendData, 0, sendData.length));
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, TRANSACTION_SERVER_CGI);
            post = new HttpPost(TRANSACTION_SERVER_CGI);
            post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                MyLog.info("Device", "status code!=200");
                MyLog.info("Device", "response when not 200 =" + EntityUtils.toString(response.getEntity()));
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(Base64.decode(new String(sb))));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            MyLog.info("Device", "ConnectionException");
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            MyLog.info("Device", "SocketException");
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            MyLog.info("Device", "SocketTimeoutException");
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            MyLog.info("Device", "IOException");
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            MyLog.info("Device", "other exception");
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel sendTransactionSignToMicrofinanceServer(String merchantID, String strCardHolderSign) {
        String data = merchantID + "|" + strCardHolderSign;
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, MICROFINANCE_UPLOAD_SIGN_SERVER_CGI);
            post = new HttpPost(MICROFINANCE_UPLOAD_SIGN_SERVER_CGI);
            // post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("p", data));
            post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    // light add for wu hao ling sign
    /*modify by lucien for  nFlag 0  1 */
    public ResultModel sendWuHaoLingTransactionSign(String merchantId, String sign, Integer nFlag) {
        byte[] head = Device.nativeFunction2034(device);
        byte[] body = Device.nativeFunction2035(device, merchantId, sign, nFlag);
        byte[] padding = new byte[1];
        byte[] sendData = Device.nativeFunction61(device, head, intToFourByte(body.length), body, padding);
        String xmlString = "p=" + URLEncoder.encode(Base64.encode(sendData, 0, sendData.length));
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, TRANSACTION_SERVER_CGI);
            post = new HttpPost(TRANSACTION_SERVER_CGI);
            MyLog.d(TAG, xmlString);
            post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));

            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(Base64.decode(new String(sb))));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel upLoadFileToAdWebServer(String merchantID, String strCardHolderSign) {
        String data = merchantID + "|" + strCardHolderSign;
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, AD_UPLOAD_PHOTO_SERVER_CGI);
            post = new HttpPost(AD_UPLOAD_PHOTO_SERVER_CGI);
            // post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("p", data));
            post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel upLoadFileToTuiTuiWebServer(String merchantID, String strCardHolderSign) {
        String data = merchantID + "|" + strCardHolderSign;
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, TUITUI_UPLOAD_PHOTO_SERVER_CGI);
            post = new HttpPost(TUITUI_UPLOAD_PHOTO_SERVER_CGI);
            // post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("p", data));
            post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel upLoadFileToWebServer(String merchantID, String strCardHolderSign, String url) {
        String data = merchantID + "|" + strCardHolderSign;
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, url);
            post = new HttpPost(url);
            // post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("p", data));
            post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    /**
     * ?POST
     *
     * @param url
     * @param params
     * @return
     */
    public ResultModel postUrlGetDataToServerReturnData(String url, List<NameValuePair> params) {
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, url);
            post = new HttpPost(url);
            post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }

    }

    /**
     * ?GET
     *
     * @param url URL
     * @return
     */
    public ResultModel sendUrlGetDataToServerReturnData(String url) {
        StringBuilder builder = new StringBuilder();
        HttpParams httpParameters = new BasicHttpParams();
        builder.append(url);
        HttpConnectionParams.setConnectionTimeout(httpParameters, 20 * 1000);
        HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
        //        HttpClient client = new DefaultHttpClient(httpParameters);
        HttpClient client = MyHttps.getNewHttpClient(httpParameters);
        MyLog.d(TAG, builder.toString());
        HttpGet get = new HttpGet(builder.toString());
        if (!isWifiEnabled) {
            String strProxyHost = android.net.Proxy.getDefaultHost();
            if (strProxyHost != null && strProxyHost.length() > 0) {
                int nPort = android.net.Proxy.getDefaultPort();
                get.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
            }
        }
        HttpResponse response;
        try {
            response = client.execute(get);
            StringBuffer sb = new StringBuffer();
            if (response.getStatusLine().getStatusCode() == 200) {
                HttpEntity entity = response.getEntity();
                InputStream is = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(is));
                String line = null;
                while (true) {
                    line = reader.readLine();
                    if (line == null) {
                        break;
                    } else {
                        sb.append(line);
                    }
                }
                reader.close();
                is.close();
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            if (url.startsWith(QUERY_O2O_LED)) {
                return new ResultModel(XML.toJSONObject(new String(sb)).toString());
            } else if (url.equals(UPDATE_APK_DOWNLOAD_URL)) {
                return new ResultModel(XML.toJSONObject(new String(sb)).toString());
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {// Base64 exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    public ResultModel uploadFile(String filePath, String userName) {
        SimpleDateFormat dataFormat = new SimpleDateFormat("yyyyMMddHHmmss");
        String nowDataStr = dataFormat.format(new Date());
        String para = android.os.Build.MODEL + "_" + userName + "_" + nowDataStr + ".data";
        // String para = "LG P970" + "_" + userName + "_" + nowDataStr +
        // ".data";
        para = URLEncoder.encode(para);
        para = para.replaceAll("\\+", "%20");
        String strUrl = UPLOAD_FILE_SERVER_CGI + "?filename=" + para;
        String result = "";
        try {
            InputStream is = new FileInputStream(filePath);
            String strLength = is.available() + "";
            URL url = new URL(strUrl);
            //            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            HttpURLConnection conn = MyHttps.getHttpURLConnection(url);
            conn.setReadTimeout(10 * 1000);
            conn.setConnectTimeout(10 * 1000);
            conn.setDoInput(true); // ??
            conn.setDoOutput(true); // ??
            conn.setUseCaches(false); // ??
            conn.setRequestMethod("POST"); // ?
            conn.setRequestProperty("Coentent_Length", strLength);
            conn.setRequestProperty("Content-Type", "application/octet-stream");
            DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
            // StringBuffer sb = new StringBuffer();
            // sb.append("p=");
            // dos.write(sb.toString().getBytes());
            byte[] bytes = new byte[10240];
            int len = 0;
            while ((len = is.read(bytes)) != -1) {
                // String xmlString = URLEncoder.encode(Base64.encode(bytes, 0,
                // len));
                // byte[] sendData = xmlString.getBytes("UTF-8");
                // dos.write(sendData, 0, sendData.length);
                dos.write(bytes, 0, len);
            }
            is.close();
            dos.flush();
            dos.close();
            /**
             * ??? 200=? ?????
             */
            int res = conn.getResponseCode();
            if (res == 200) {
                InputStream input = conn.getInputStream();
                StringBuffer sb1 = new StringBuffer();
                int ss;
                while ((ss = input.read()) != -1) {
                    sb1.append((char) ss);
                }
                result = sb1.toString();
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(result));

        } catch (MalformedURLException e) {
            e.printStackTrace();
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (IOException e) {
            e.printStackTrace();
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        } catch (KeyManagementException e) {
            e.printStackTrace();
            return new ResultModel(Device.TRANSACTION_NET_FAIL);
        }
    }

    public ResultModel getOrderTicketQRCode(String payorderId) {
        StringBuffer url = new StringBuffer();
        url.append(ORDER_TICKET_QR_CODE).append("?orderId=").append(payorderId);
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    // ===== Char add 2015-07-15 ??

    /**
     * ???
     *
     * @param i
     * @return
     * @author "Char"
     * @create_date 2015-7-15
     */
    public ResultModel getCreditCardSupportBankList(String i) {
        byte[] head = Device.nativeFunction1066(device);
        byte[] body = Device.nativeFunction1067(device);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ??????
     *
     * @param phoneNum
     * @return
     * @author "Char"
     * @create_date 2015-7-15
     * <p/>
     * update 2015-06-15 terence checkcode ? ??
     * ????
     */
    public ResultModel getSMSCheckCode(String phoneNum, String checkCode) {
        byte[] head = Device.nativeFunction1068(device);
        byte[] body = Device.nativeFunction1069(device, phoneNum, checkCode);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ?
     *
     * @param i
     * @return
     * @author "Char"
     * @create_date 2015-7-16
     */
    public ResultModel queryRealNamePaymentBindCard(String i) {
        byte[] head = Device.nativeFunction1060(device);
        byte[] body = Device.nativeFunction1061(device);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ???
     *
     * @param cardID
     * @return
     * @author "Char"
     * @create_date 2015-7-17
     */
    public ResultModel checkCreditUsedHistory(String cardID) {
        byte[] head = Device.nativeFunction1062(device);
        byte[] body = Device.nativeFunction1063(device, cardID);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ??
     *
     * @param strCardID
     * @param strCardBankCode
     * @param strCardBankName
     * @param strPayOrderID
     * @param strPhoneNo
     * @param strCardCVV
     * @param strAccountName
     * @param strCertType
     * @param strCertID
     * @param strVerifyCode
     * @param strCardValid
     * @return
     * @author "Char"
     * @create_date 2015-7-17
     */
    public ResultModel realnamePayAuthentication(String strCardID, String strCardBankCode, String strCardBankName,
            String strPayOrderID, String strPhoneNo, String strCardCVV, String strAccountName, String strCertType,
            String strCertID, String strVerifyCode, String strCardValid) {
        byte[] head = Device.nativeFunction1054(device);
        byte[] body = Device.nativeFunction1055(device, strCardID, strCardBankCode, strCardBankName, strPayOrderID,
                strPhoneNo, strCardCVV, strAccountName, strCertType, strCertID, strVerifyCode, strCardValid);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ??
     *
     * @param strCardID
     * @param verifyCode
     * @return
     */
    public ResultModel realnamePayAuthenticationForChecked(String strCardID, String verifyCode) {
        byte[] head = Device.nativeFunction1072(device);
        byte[] body = Device.nativeFunction1073(device, strCardID, verifyCode);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ??
     *
     * @param url
     * @param session_id
     * @return
     * @author "Char"
     * @create_date 2015-7-18
     */
    public ResultModel realnamePayApplication(String username, String session_id, String data, String url) {
        return sendPostDataToRealnamePayWebServer(username, session_id, data, url);
    }

    /**
     * ??
     *
     * @param username
     * @param session_id
     * @param data
     * @param url
     * @return
     * @author "Char"
     * @create_date 2015-7-18
     */
    public ResultModel realnamePayUploadIDCard(String username, String session_id, String data, String url) {
        return sendPostDataToRealnamePayWebServer(username, session_id, data, url);
    }

    /**
     * ??
     *
     * @param username
     * @param session_id
     * @param url
     * @return
     * @author "Char"
     * @create_date 2015-7-18
     */
    public ResultModel realnameQueryApplicationState(String username, String session_id, String url) {
        return sendPostDataToRealnamePayWebServer(username, session_id, null, url);
    }

    /**
     * ??
     *
     * @param strPayOrderID
     * @param nAmount
     * @param strPinpadID
     * @param strTrack2Data
     * @param strPin
     * @param strLongitude
     * @param strLatitude
     * @param strDiffuseFactor
     * @param deviceType
     * @param versionType
     * @param strVerifyCode
     * @param strGoodsName
     * @return
     * @author "Char"
     * @create_date 2015-7-20
     */
    public ResultModel doRealnamePayment(String strPayOrderID, Integer nAmount, String strPinpadID,
            String strTrack2Data, String strPin, String strLongitude, String strLatitude, String strDiffuseFactor,
            Integer deviceType, Integer versionType, String strVerifyCode, String strGoodsName, Integer t0flag) {
        byte[] head = Device.nativeFunction1058(device);
        byte[] body = Device.nativeFunction1059(device, strPayOrderID, nAmount, strPinpadID, strTrack2Data, strPin,
                strLongitude, strLatitude, strDiffuseFactor, deviceType, versionType, strVerifyCode, strGoodsName,
                "1", t0flag);
        //MyLog.info("doRealnamePayment","t0flag="+t0flag+"sting="+new String(body,body.length-7,7));
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ???
     *
     * @param nPageSize
     * @param nPageNo
     * @param strStartDate
     * @param strEndDate
     * @param strType
     * @return
     * @author "Char"
     * @create_date 2015-7-20
     */
    public ResultModel queryRealNamepayHistoryList(Integer nPageSize, Integer nPageNo, String strStartDate,
            String strEndDate, String strType) {
        byte[] head = Device.nativeFunction2036(device);
        byte[] body = Device.nativeFunction2037(device, nPageSize, nPageNo, strStartDate, strEndDate, strType);
        return sendCommandPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head, body);
    }

    /**
     * ???
     *
     * @param orderId
     * @return
     * @author "Char"
     * @create_date 2015-7-21
     */
    public ResultModel getRealNamepayHistoryItemDetail(String orderId) {
        byte[] head = Device.nativeFunction1064(device);
        byte[] body = Device.nativeFunction1065(device, orderId);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ??-??
     *
     * @param orderId
     * @return
     * @author "Char"
     * @create_date 2015-7-21
     */
    public ResultModel getRealNamepayResult(String orderId) {
        byte[] head = Device.nativeFunction1064(device);
        byte[] body = Device.nativeFunction1065(device, orderId);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ?
     *
     * @param strCardID
     * @return
     * @author "Char"
     * @create_date 2015-7-21
     */
    public ResultModel doRealNamepayCreditCardUnbingding(String strCardID) {
        byte[] head = Device.nativeFunction1056(device);
        byte[] body = Device.nativeFunction1057(device, strCardID);
        return sendSecurityPackageToRealnamePayServerAndReturnResultModel(REALNAME_PAYMENT_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ?????? -- POST
     *
     * @param proxy
     * @param head
     * @param nPackage
     * @param data
     * @return
     * @author "Char"
     * @create_date 2015-7-15
     */
    private ResultModel postSecurityPackageToRealnamePayServerAndReturnResultModel(int proxy, byte[] head,
            int nPackage, byte[] data) {
        return postDataToServer(proxy, head, intToFourByte(nPackage), data);
    }

    /**
     * ???????-- GET
     *
     * @param command
     * @param data
     * @return
     * @author "Char"
     * @create_date 2015-7-20
     */
    private ResultModel sendCommandPackageToRealnamePayServerAndReturnResultModel(int proxy, byte[] command,
            byte[] data) {
        byte[] padding = new byte[1];
        return sendDataToServer(proxy, command, intToFourByte(data.length), data, padding);
    }

    /**
     * ??????-- GET
     *
     * @param proxy
     * @param head
     * @param nPackage
     * @param data
     * @return
     * @author "Char"
     * @create_date 2015-7-15
     */
    private ResultModel sendSecurityPackageToRealnamePayServerAndReturnResultModel(int proxy, byte[] head,
            int nPackage, byte[] data) {
        return sendDataToServer(proxy, head, intToFourByte(nPackage), data);
    }

    /**
     * ???web????????<br>
     * ?"\\|"+Base64
     *
     * @param username
     * @param session_id
     * @param data
     * @param url
     * @return
     * @author "Char"
     * @create_date 2015-7-18
     */
    public ResultModel sendPostDataToRealnamePayWebServer(String username, String session_id, String data,
            String url) {
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, url);
            post = new HttpPost(url);
            // post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("username", username));
            params.add(new BasicNameValuePair("session_id", session_id));
            if (data == null) {

            } else if (data.startsWith("\\|")) {
                params.add(new BasicNameValuePair("p", data));
            } else {
                params.add(new BasicNameValuePair("idcardHandImg", data));
            }
            post.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            // exception
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    // =====

    // =====Char add 2015-08-11 

    /**
     * --?
     *
     * @param username  ??
     * @param sessionId session ID
     * @return
     * @author "Char"
     * @create_date 2015-8-11
     */
    public ResultModel queryQuickenLoansUserCreditInfo(String username, String sessionId) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_QUERY_USER_CREDIT_INFO);
        url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionId);
        System.out.println("? URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * ??,???
     *
     * @param username
     * @param sessionId
     * @param jsonStr
     * @return
     * @author "Char"
     * @create_date 2015-8-19
     * @update_data 2015-09-24
     */
    public ResultModel doQuickenLoansSendCreditAndApply(String username, String sessionId, Integer type,
            String jsonStr) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        if (type == 0) {
            url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_SEND_CREDIT_INFO_AND_APPLY);
            url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionId);
            //terence add 2016-02-17   v=2.0.0
            url.append("&v=2.0.0");
            //            System.out.println("? URL = " + url.toString());
        } else {
            url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_SAVE_ITEM);
            url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionId);
            url.append("&").append("type=").append(type);
            //            System.out.println("??? URL = " + url.toString());
        }
        MyLog.d(TAG, jsonStr);
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            MyLog.d(TAG, url.toString());
            post = new HttpPost(url.toString());
            // post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            post.setEntity(new StringEntity(jsonStr, HTTP.UTF_8));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }

            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(sb));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    /**
     * ?
     *
     * @param username  ??
     * @param sessionId
     * @return
     * @author "Char"
     * @create_date 2015-8-11
     */
    public ResultModel queryQuickenLoansStatus(String username, String sessionId) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_QUERY_LOAN_STATUS);
        url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionId)
                .append("&v=2.1.0");
        System.out.println("? URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * POS?
     *
     * @param username
     * @param sessionId
     * @return
     * @author "Char"
     * @create_date 2015-8-21
     */
    public ResultModel checkQuickenLoansUserPos(String username, String sessionId, String applyId) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_CHECK_USER_POS);
        url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionId)
                .append("&applyId=").append(applyId);
        System.out.println("? URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * ?
     *
     * @param pageIndex ?1
     * @param pageSize
     * @param username
     * @param sessionid
     * @return
     * @author "Char"
     * @create_date 2015-8-21
     */
    public ResultModel queryQuickenLoansClosedBillList(Integer pageIndex, Integer pageSize, String username,
            String sessionid) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_QUICKEN_CLOSED_BILL);
        url.append("?").append("pageIndex=").append(pageIndex).append("&").append("pageSize=").append(pageSize)
                .append("&").append("username=").append(username).append("&").append("sessionid=")
                .append(sessionid);
        System.out.println("?URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * ??
     *
     * @param username
     * @param sessionid
     * @param type      1=?2=
     * @return
     * @author "Char"
     * @create_date 2015-8-21
     * <p/>
     * terence updated 2016-03-14 applyId
     */
    public ResultModel getQuickenLoansOrderId(String username, String sessionid, String applyId, Integer type) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_GET_LOAN_ORDER);
        url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionid)
                .append("&").append("type=").append(type).append("&").append("applyId=").append(applyId);
        ;
        System.out.println("?? URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * 
     *
     * @param username
     * @param sessionid
     * @param type      1=?2=
     * @param billid
     * @return
     * @author "Char"
     * @create_date 2015-8-21
     * <p/>
     * terence changed 2016-02-01
     * <p/>
     * ????? isAdvance
     * <p/>
     * ????  ???1?0?
     */
    public ResultModel doQuickenLoansRepayment(String username, String sessionid, Integer type, String billid,
            String isAdvance) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_REPAYMENT_ORDER);
        url.append("?").append("username=").append(username).append("&").append("sessionid=").append(sessionid)
                .append("&").append("type=").append(type).append("&").append("billid=").append(billid)
                .append("&isAdvance=").append(isAdvance);
        System.out.println(" URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * 
     *
     * @param strPayOrderID
     * @param nAmount
     * @param strLongitude
     * @param strLatitude
     * @param strCardID
     * @param strGoodsName
     * @return
     * @author "Char"
     * @create_date 2015-9-9
     */
    public ResultModel doQuickenLoansPayment(String strPayOrderID, Integer nAmount, String strLongitude,
            String strLatitude, String strCardID, String strGoodsName) {
        System.out.println("");
        byte[] head = Device.nativeFunction1070(device);
        byte[] body = Device.nativeFunction1071(device, strPayOrderID, nAmount, strLongitude, strLatitude,
                strCardID, strGoodsName);
        return sendSecurityPackageToQuickenLoansServerAndReturnResultModel(QUICKEN_LOANS_PROXY, head,
                Device.nativeFunction66(device), body);
    }

    /**
     * ?
     *
     * @param username
     * @param session_id
     * @param type       
     * @param path       ?
     * @return
     * @author "Char"
     * @create_date 2015-8-18
     */
    public ResultModel sendIDCardToQuickenLoansServer(String username, String session_id, Integer type,
            String path) {
        String url = QUICKEN_LOANS_ROOT + QUICKEN_LOANS_PHOTO_UPLOAD;
        StringBuffer urlAction = new StringBuffer(url);
        username = URLEncoder.encode(username);
        urlAction.append("?").append("username=").append(username).append("&").append("sessionid=")
                .append(session_id).append("&").append("type=").append(type);
        System.out.println("? URL = " + urlAction.toString());
        return sendPhotoToQuickenLoansWebServer(urlAction.toString(), new File(path));
    }

    public ResultModel doDeleteQuickenLoansCreditInfo(String username, String session_id, Integer type,
            Integer id) {
        StringBuffer url = new StringBuffer();
        username = URLEncoder.encode(username);
        url.append(QUICKEN_LOANS_ROOT).append(QUICKEN_LOANS_DELETE_CREDITINFO);
        url.append("?").append("username=").append(username).append("&").append("sessionid=").append(session_id)
                .append("&").append("type=").append(type).append("&").append("id=").append(id);
        System.out.println("?URL = " + url.toString());
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * ??????-- GET
     *
     * @param proxy
     * @param head
     * @param nPackage
     * @param data
     * @return
     * @author "Char"
     * @create_date 2015-7-15
     */
    private ResultModel sendSecurityPackageToQuickenLoansServerAndReturnResultModel(int proxy, byte[] head,
            int nPackage, byte[] data) {
        return sendDataToServer(proxy, head, intToFourByte(nPackage), data);
    }

    /**
     * ?
     *
     * @param actionUrl ?
     * @param file      
     * @return
     * @author "Char"
     * @create_date 2015-8-18
     */
    private ResultModel sendPhotoToQuickenLoansWebServer(String actionUrl, File file) {
        try {
            int TIME_OUT = 10 * 1000; // 
            String CHARSET = "utf-8"; // ?
            String result = null;
            String BOUNDARY = UUID.randomUUID().toString(); //  ??
            String PREFIX = "--", LINE_END = "\r\n";
            String CONTENT_TYPE = "multipart/form-data"; // 

            URL url = new URL(actionUrl);
            //            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            HttpURLConnection conn = MyHttps.getHttpURLConnection(url);
            conn.setReadTimeout(TIME_OUT);
            conn.setConnectTimeout(TIME_OUT);
            conn.setDoInput(true); // ??
            conn.setDoOutput(true); // ??
            conn.setUseCaches(false); // ??
            conn.setRequestMethod("POST"); // ?
            conn.setRequestProperty("Charset", CHARSET); // ?
            conn.setRequestProperty("connection", "keep-alive");
            conn.setRequestProperty("Content-Type", CONTENT_TYPE + ";boundary=" + BOUNDARY);

            if (file != null) {
                /**
                 * ?
                 */
                DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
                StringBuffer sb = new StringBuffer();
                sb.append(PREFIX);
                sb.append(BOUNDARY);
                sb.append(LINE_END);
                /**
                 * ?? name???key ?key ??
                 * filename??????
                 */

                sb.append("Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getName() + "\""
                        + LINE_END);
                sb.append("Content-Type: application/octet-stream; charset=" + CHARSET + LINE_END);
                sb.append(LINE_END);
                dos.write(sb.toString().getBytes());
                InputStream is = new FileInputStream(file);
                byte[] bytes = new byte[1024];
                int len = 0;
                while ((len = is.read(bytes)) != -1) {
                    dos.write(bytes, 0, len);
                }
                is.close();
                dos.write(LINE_END.getBytes());
                byte[] end_data = (PREFIX + BOUNDARY + PREFIX + LINE_END).getBytes();
                dos.write(end_data);
                dos.flush();
            }
            // ??
            int res = conn.getResponseCode();
            InputStream in = conn.getInputStream();
            InputStreamReader isReader = new InputStreamReader(in);
            BufferedReader bufReader = new BufferedReader(isReader);
            String line = null;
            String data = "";

            StringBuilder sb2 = new StringBuilder();
            if (res == 200) {
                while ((line = bufReader.readLine()) != null) {
                    data += line;
                }
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            in.close();
            conn.disconnect();
            return new ResultModel(data);
        } catch (MalformedURLException e) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, e);
        } catch (IOException e) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, e);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return new ResultModel(Device.TRANSACTION_NET_FAIL, e);
        } catch (KeyManagementException e) {
            e.printStackTrace();
            return new ResultModel(Device.TRANSACTION_NET_FAIL, e);
        }
    }

    public ResultModel payQuickenLoans(String cardId) {
        return leshuaDevice.payQuickenLoans(cardId);
    }

    // =====

    /**
     * ??
     *
     * @param osType
     * @param appType
     * @param appVersion
     * @param screenWidth
     * @param screenHeight
     * @return
     */
    public ResultModel getAdMessage(String osType, String appType, String appVersion, String screenWidth,
            String screenHeight) {
        StringBuffer url = new StringBuffer(AD_MESSAGE);
        url.append("?osType=").append(osType);
        url.append("&appType=").append(appType);
        url.append("&appVersion=").append(appVersion);
        url.append("&screenWidth=").append(screenWidth);
        url.append("&screenHeight=").append(screenHeight);
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * ?-???
     *
     * @param merchantId
     * @return
     */
    public ResultModel queryBitFlag(String merchantId) {
        StringBuffer url = new StringBuffer(QUERY_BIT_FLAG);
        url.append("?merchantId=").append(merchantId);
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     * ?-
     *
     * @param merchantId
     * @param type
     * @param isDone
     * @return
     */
    public ResultModel updateBitFlag(String merchantId, String type, String isDone) {
        StringBuffer url = new StringBuffer(UPDATE_BIT_FLAG);
        url.append("?merchantId=").append(merchantId);
        url.append("&type=").append(type);
        url.append("&isDone=").append(isDone);
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /**
     */
    public ResultModel uploadHeadPicSrc(String merchantId, String head) {
        StringBuffer url = new StringBuffer(UPLOAD_HEAD);
        url.append("?merchantId=").append(merchantId);
        url.append("&head=").append(head);
        return sendUrlGetDataToServerReturnData(url.toString());
    }

    /*???*/

    public ResultModel sendResign(String merchantID, String payOrderID, String transactionId,
            String strCardHolderSign) {
        byte[] head = Device.nativeFunction10008(device);
        byte[] body = Device.nativeFunction10009(device, merchantID, payOrderID, transactionId, strCardHolderSign);
        byte[] padding = new byte[1];
        byte[] sendData = Device.nativeFunction61(device, head, intToFourByte(body.length), body, padding);
        String xmlString = "p=" + URLEncoder.encode(Base64.encode(sendData, 0, sendData.length));
        MyLog.d(TAG, xmlString);
        try {
            HttpParams httpParameters = new BasicHttpParams();
            HttpConnectionParams.setConnectionTimeout(httpParameters, 60 * 1000);
            HttpConnectionParams.setSoTimeout(httpParameters, 60 * 1000);
            //            HttpClient client = new DefaultHttpClient(httpParameters);
            HttpClient client = MyHttps.getNewHttpClient(httpParameters);
            HttpPost post = null;
            post = new HttpPost(TRANSACTION_SERVER_CGI);
            MyLog.d(TAG, TRANSACTION_SERVER_CGI);
            post.setEntity(new ByteArrayEntity(xmlString.getBytes("UTF-8")));
            if (!isWifiEnabled) {
                String strProxyHost = android.net.Proxy.getDefaultHost();
                if (strProxyHost != null && strProxyHost.length() > 0) {
                    int nPort = android.net.Proxy.getDefaultPort();
                    post.getParams().setParameter(ConnRouteParams.DEFAULT_PROXY, new HttpHost(strProxyHost, nPort));
                }
            }
            HttpResponse response;
            response = client.execute(post);
            StringBuffer sb = new StringBuffer();
            int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                String strResult = EntityUtils.toString(entity);
                sb.append(strResult);
            } else {
                return new ResultModel(Device.TRANSACTION_NET_FAIL);
            }
            return new ResultModel(new String(Base64.decode(new String(sb))));
        } catch (org.apache.http.conn.HttpHostConnectException ex) {// connect
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.net.SocketTimeoutException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (ClientProtocolException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (java.io.IOException ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        } catch (Exception ex) {
            return new ResultModel(Device.TRANSACTION_NET_FAIL, ex);
        }
    }

    private final static int LOGIN_SERVER_PROXY = 0;
    private final static int TRANSACTION_SERVER_PROXY = 1;
    private final static int LESHUA_TRANSACTION_SERVER_PROXY = 2;
    private final static int LED_SERVER_PROXY = 3;
    private final static int HONGBAO_SERVER_PROXY = 4;
    private final static int GPRS_PRINTER_SERVER_PROXY = 5;
    private final static int REALNAME_PAYMENT_PROXY = 6; // Char add 2015-07-16
    // ??
    private final static int QUICKEN_LOANS_PROXY = 7; // Char add 2015-07-16 

    // ??
    public final static String QUICKEN_LOANS_QUERY_USER_CREDIT_INFO = "/user/user-credit-info.do"; // Char
    // add
    // 2015-08-10
    // web?--?
    public final static String QUICKEN_LOANS_SEND_CREDIT_INFO_AND_APPLY = "/loan/save_loan_material.do"; // Char
    // add
    // 2015-08-10
    // web?--???/
    public final static String QUICKEN_LOANS_PHOTO_UPLOAD = "/photo/upload.do"; // Char
    // add
    // 2015-08-10
    // web?--
    public final static String QUICKEN_LOANS_QUERY_LOAN_STATUS = "/loan/query_loan_status.do"; // Char
    // add
    // 2015-08-10
    // web?--??
    public final static String QUICKEN_LOANS_CHECK_USER_POS = "/loan/check_user_pos.do"; // Char
    // add
    // 2015-08-10
    // web?--pos???
    public final static String QUICKEN_LOANS_QUICKEN_CLOSED_BILL = "/loan/query_closed_bill.do"; // Char
    // add
    // 2015-08-10
    // web?--?()
    public final static String QUICKEN_LOANS_GET_LOAN_ORDER = "/loan/pay_loan_fee.do"; // Char
    // add
    // 2015-08-10
    // web?--???
    public final static String QUICKEN_LOANS_REPAYMENT_ORDER = "/loan/repayment_order.do"; // Char
    // add
    // 2015-08-10
    // web?--
    public final static String QUICKEN_LOANS_SAVE_ITEM = "/user/sava_creditinfo.do"; // Char
    // add
    // 2015-09-23
    // web?--???
    public final static String QUICKEN_LOANS_CONTRACT_CREDIT_AUTHORIZATION = "/contract/creditauthorization.do"; // Char

    // lucien
    // 2016-09-09
    // web?--????
    public final static String QUICKEN_LOANS_CONTRACT_PERSONCREDIT = "/contract/personcredit.do"; // lucien

    // add
    // 2015-09-29
    // web?--????
    public final static String QUICKEN_LOANS_CONTRACT_LOAN_AGREEMENT = "/contract/loanagreement.do"; // Char
    // add
    // 2015-09-29
    // web?--???
    public final static String QUICKEN_LOANS_CONTRACT_WITH_HOLD_AUTHORIZATION = "/contract/withholdauthorization.do"; // Char
    // add
    // 2015-09-29
    // web?--???
    public final static String QUICKEN_LOANS_CONTRACT_LOAN_AGREEMTN_DETAIL = "/contract/loanAgreementDetail.do"; // Char
    // add
    // 2015-09-29
    // web?--??
    public final static String QUICKEN_LOANS_DELETE_CREDITINFO = "/user/delete_creditinfo.do"; // Char
    // add
    // 2015-10-14
    // web?--?

    public static String BASE_TPLUS0_URL = "https://mobilepostest2.yeahka.com";
    private static String LOGIN_SERVER_CGI = "https://mobilepostest2.yeahka.com/cgi-bin/lepos_login_proxy.cgi";
    private static String TRANSACTION_SERVER_CGI = "https://mobilepostest2.yeahka.com/cgi-bin/lepos_proxy.cgi"; // lepos_proxy_for_t0
    private static String CARD_TRANS_INFO_SERVER_CGI = "https://mobiletest.yeahka.com/cgi-bin/leshua_config.cgi";
    private static String CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://mobileykpay.yeahka.com/cgi-bin/ykpayquery.cgi";
    private static String OLD_CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://mobiletest.yeahka.com/cgi-bin/leshua_query.cgi";
    private static String UPLOAD_FILE_SERVER_CGI = "http://mobilepos.yeahka.com:9080/cgi-bin/lepos_upload_file.cgi";
    private static String SMS_STORE_SERVER_CGI = "https://postest2.yeahka.com/posadmin/home/";
    private static String UPDATE_SELECT_CONNCET_TYPE_CGI = "http://pos.yeahka.com:9080/leposweb/app/getMobileUseInfo.do";
    private static String MICROFINANCE_UPLOAD_SIGN_SERVER_CGI = "https://postest2.yeahka.com/leposweb/credit/signpost.do";
    public static String MICROFINANCE_UPLOAD_SIGN_RESULT_SERVER_CGI = "https://postest2.yeahka.com/leposweb/credit/signsuccess.do";
    public static String MICROFINANCE_CHECK_CITY_SERVER_CGI = "https://postest2.yeahka.com/leposweb/credit/citycheck.do";
    public static String AD_UPLOAD_PHOTO_SERVER_CGI = "https://postest2.yeahka.com/leposweb/adv/picpost.do";
    public static String MACH_CHECK_AD_HIS_SERVER_CGI = "https://postest2.yeahka.com/leposweb/adv/checkpost.do";
    public static String WECHAT_PAY_WEB_SERVER_CGI;
    public static String WECHAT_PAY_WEB_GET_FEE_RATE_SERVER_CGI = "https://postest2.yeahka.com/leposweb/mobile/getWXOpenInfo.do";
    public static String WECHAT_PAY_WEB_CREATE_ORDER_SERVER_CGI = "https://postest2.yeahka.com/posadmin/home/getWXOrders.do";
    public static String USER_LOGIN_AD_URL = "https://postest2.yeahka.com/leposweb/mobile/wei_ad.do";
    public static String USER_OPEN_READ_CARD_URL = "https://postest2.yeahka.com/leposweb/mobile/get_switch.do";
    public static String USERlOGIN_AD_DEFUAL_URL = "https://postest2.yeahka.com/leposweb/mobile/ad_weixin.do";
    public static String TUITUI_UPLOAD_PHOTO_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/picpost.do";
    public static String TUITUI_CANCLE_WECHAT_SHARE_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/updateweixin.do";
    public static String QUERY_TUITUI_MSG_COUNT_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/getRecommendWeiCount.do";
    public static String QUERY_ALIPAY_TIP_DILOAG_SHOW_STATUE_SERVER_CGI = "https://postest2.yeahka.com/leposweb/app/checkRateDiscount.do";
    public static String UPDATE_WECHAT_GOODS_TYPE_CGI = "https://postest2.yeahka.com/leposweb/home/update_product_type.do";
    public static String LESHOU_MERCHANT_ID = "10001";
    public static String QUERY_O2O_ORDER_COUNT_SERVER_CGI = "https://wxs.yeahka.com/o2o/index/query_merchant_order.do";
    public static String QUERY_TUITUI_TEXT_UPDATE_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/checkNewContentVersion.do";
    public static String BIND_O2O_USER_ORDER_INFO = "https://wxs.yeahka.com/o2o/index/set_channel_id.do";
    public static String QUERY_O2O_ORDER_INFO_SERVER_CGI = "https://wxs.yeahka.com/o2o/index/deal_detail.do";
    public static String LED_SERVER_CGI = "https://ykproxytest.yeahka.com/cgi-bin/o2o_business.cgi";
    public static String HONGBAO_SERVER_CGI = "https://ykproxytest.yeahka.com/cgi-bin/o2o_business2.cgi";
    public static String GPRS_SERVER_CGI = "https://ykproxytest.yeahka.com/cgi-bin/o2o_business.cgi";
    public static String WISDOM_MALL_SERVER_CGI = "https://wxs.yeahka.com/mall/app/";
    public static String REGISTER_HOST = "192.168.21.243";
    public static int REGISTER_PORT = 8061;
    public static String REALNAME_PAYMENT_UPLOAD_IDCARD = "https://businesstest.yeahka.com/leposweb/mobile/upload_img.do"; // Char
    public static String REALNAME_PAYMENT_APPLICATION = "https://businesstest.yeahka.com/leposweb/mobile/certpayapply.do"; /*2015-07-16????????*/
    public static String REALNAME_PAYMENT_QUERY_APPLECATION_STATE = "https://businesstest.yeahka.com/leposweb/mobile/certpaystatus.do";// add 2015-07-18 ?????
    public static String QUERY_O2O_LED = "https://o2o.yeahka.com/cgi-bin/o2o_led_query.cgi";// add 2015-07-18 ????
    public static String UPDATE_APK_DOWNLOAD_URL = "https://mobileykpay.yeahka.com/cgi-bin/downloadxml.cgi";// add 2015-08-28 ??SN?SN?
    public static String QUICKEN_LOANS_ROOT = "http://113.108.69.130:43100/yeahka-fastloan";// add 2015-09-23 ????
    public static String QUICKEN_LOANS_BASE = "http://113.108.69.130:43100";// Char
    public static String ORDER_TICKET_QR_CODE = "https://pos.yeahka.com/leposweb/home/getOrderQrCode.do";// add 2015-08-10 web?--?
    public static String O2O_PROXY = "https://o2o.yeahka.com/o2o_proxy/";// add 2015-10-28 ????
    public static String AD_MESSAGE = "https://app.yeahka.com/leshua/adv/advInfo.do";//
    public static String UPLOAD_PIC_TO_WEB_SERVER = "https://wxs.yeahka.com/o2o/upload/upload_img_new.do";
    public static String QUERY_BIT_FLAG = "https://wxs.yeahka.com/o2o/pay/queryBitFlag.do";
    public static String UPDATE_BIT_FLAG = "https://wxs.yeahka.com/o2o/pay/updateBitFlag.do";
    public static String UPLOAD_HEAD = "https://wxs.yeahka.com/o2o/pay/uploadHead.do";
    public static String BASE_WEB_URL = "https://businesstest.yeahka.com";
    public static String BASE_AD_URL = "https://postest2.yeahka.com";
    public static String SCAN_CODE_PAY_BASEURL = "https://wxs.yeahka.com/o2o/pay/merchant_shop_url.do?";
    public static String QUICKEN_LOANS_ROOT_PERSON_CREDIT_REPORT = "https://p2ptest.yeahka.com/yeahka-fastloan/loan/query_loan_status.do?";
    public static String SWITCH_APP_BASE_URL = "https://www.yeahka.com";
    public static String MERCHANT_DATA_LIMIT_HOST = "http://pos.yeahka.com";
    public static String GENERAL_AD_HOST = "http://pos.yeahka.com";
    public static String NOTICE_SYSNEWS_HOST = "http://pos.yeahka.com";
    public static String ABOAT_LESHUA_IBEACON = "https://www.yeahka.com/wap/swiper/ibeacon.html";
    public static String ABOAT_LESHUA_SHANGHUIBAO = "https://www.yeahka.com/wap/swiper/shanghuibao.html";
    public static String MACH_PUBLISH_AD_URL = "https://pos.yeahka.com/leposweb/adv/index.do";
    public static String MACH_AD_HIS_URL = "https://pos.yeahka.com/leposweb/adv/preview.do";
    public static String LEPOS_HELP_CENTER = "https://mobilepos.yeahka.com/help_index_new.html";
    public static String CREDITCARDREPAYMENT_README = "https://app.yeahka.com/creditcardrepayment/readme.html";
    public static String GET_APK_CHANNEL_INFO = "https://pos.yeahka.com/leposweb/";
    public static String YEAHKA_WEB_HOST = "https://postest2.yeahka.com";/*web??*/

    public static String QPAY_HOST_PORT = "https://mobilepostest2.yeahka.com";

    static {
        switch (APP_NETWORK_ENVIRONMENT_FLAG) {
        case 1:
            LOGIN_SERVER_CGI = "https://mobilepos.yeahka.com/cgi-bin/lepos_login_proxy.cgi";
            TRANSACTION_SERVER_CGI = "https://mobilepos.yeahka.com/cgi-bin/lepos_proxy.cgi";
            CARD_TRANS_INFO_SERVER_CGI = "https://mobile.yeahka.com/cgi-bin/leshua_config.cgi";
            CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://mobileykpay.yeahka.com/cgi-bin/ykpayquery.cgi";
            OLD_CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://mobile.yeahka.com/cgi-bin/leshua_query.cgi";
            //                UPLOAD_FILE_SERVER_CGI = "https://mobilepos.yeahka.com/cgi-bin/lepos_upload_file.cgi";
            SMS_STORE_SERVER_CGI = "https://pos.yeahka.com/posadmin/home/";
            UPDATE_SELECT_CONNCET_TYPE_CGI = "https://pos.yeahka.com/leposweb/app/getMobileUseInfo.do";
            MICROFINANCE_UPLOAD_SIGN_SERVER_CGI = "https://pos.yeahka.com/leposweb/credit/signpost.do";
            MICROFINANCE_UPLOAD_SIGN_RESULT_SERVER_CGI = "https://pos.yeahka.com/leposweb/credit/signsuccess.do";
            MICROFINANCE_CHECK_CITY_SERVER_CGI = "https://pos.yeahka.com/leposweb/credit/citycheck.do";
            AD_UPLOAD_PHOTO_SERVER_CGI = "https://pos.yeahka.com/leposweb/adv/picpost.do";
            MACH_CHECK_AD_HIS_SERVER_CGI = "https://pos.yeahka.com/leposweb/adv/checkpost.do";
            WECHAT_PAY_WEB_SERVER_CGI = "https://pos.yeahka.com/leposweb/adv/checkpost.do";
            WECHAT_PAY_WEB_GET_FEE_RATE_SERVER_CGI = "https://pos.yeahka.com/leposweb/mobile/getWXOpenInfo.do";
            WECHAT_PAY_WEB_CREATE_ORDER_SERVER_CGI = "https://pos.yeahka.com/posadmin/home/getWXOrders.do";
            USER_LOGIN_AD_URL = "https://pos.yeahka.com/leposweb/mobile/wei_ad.do";
            USER_OPEN_READ_CARD_URL = "https://pos.yeahka.com/leposweb/mobile/get_switch.do";
            USERlOGIN_AD_DEFUAL_URL = "https://pos.yeahka.com/leposweb/mobile/ad_weixin.do";
            TUITUI_UPLOAD_PHOTO_SERVER_CGI = "https://pos.yeahka.com/recommend/home/picpost.do";
            TUITUI_CANCLE_WECHAT_SHARE_SERVER_CGI = "https://pos.yeahka.com/recommend/home/updateweixin.do";
            QUERY_TUITUI_MSG_COUNT_SERVER_CGI = "https://pos.yeahka.com/recommend/home/getRecommendWeiCount.do";
            QUERY_ALIPAY_TIP_DILOAG_SHOW_STATUE_SERVER_CGI = "https://pos.yeahka.com/leposweb/app/checkRateDiscount.do";
            UPDATE_WECHAT_GOODS_TYPE_CGI = "https://pos.yeahka.com/leposweb/home/update_product_type.do";
            LESHOU_MERCHANT_ID = "10101";
            QUERY_O2O_ORDER_COUNT_SERVER_CGI = "https://pos.yeahka.com/o2o/index/query_merchant_order.do";
            QUERY_TUITUI_TEXT_UPDATE_SERVER_CGI = "https://pos.yeahka.com/recommend/home/checkNewContentVersion.do";
            BIND_O2O_USER_ORDER_INFO = "https://pos.yeahka.com/o2o/index/set_channel_id.do";
            QUERY_O2O_ORDER_INFO_SERVER_CGI = "https://pos.yeahka.com/o2o/index/deal_detail.do";
            LED_SERVER_CGI = "https://o2o.yeahka.com/cgi-bin/o2o_business3.cgi";
            HONGBAO_SERVER_CGI = "https://o2o.yeahka.com/cgi-bin/o2o_business2.cgi";
            GPRS_SERVER_CGI = "https://o2o.yeahka.com/cgi-bin/o2o_business3.cgi";
            WISDOM_MALL_SERVER_CGI = "https://pos.yeahka.com/mall/app/";
            REGISTER_HOST = "umserver.yeahka.com";
            REGISTER_PORT = 45053;
            REALNAME_PAYMENT_UPLOAD_IDCARD = "https://pos.yeahka.com/leposweb/mobile/upload_img.do"; // Char
            REALNAME_PAYMENT_APPLICATION = "https://pos.yeahka.com/leposweb/mobile/certpayapply.do";// add 2015-07-16 ????????
            REALNAME_PAYMENT_QUERY_APPLECATION_STATE = "https://pos.yeahka.com/leposweb/mobile/certpaystatus.do";// add 2015-07-18 ?????
            QUERY_O2O_LED = "https://o2o.yeahka.com/cgi-bin/o2o_led_query.cgi";// add 2015-07-18 ????
            UPDATE_APK_DOWNLOAD_URL = "https://mobileykpay.yeahka.com/cgi-bin/downloadxml.cgi";// add 2015-08-28 ??SN?SN?
            QUICKEN_LOANS_ROOT = "https://p2p.yeahka.com/yeahka-fastloan";
            QUICKEN_LOANS_BASE = "https://p2p.yeahka.com";
            ORDER_TICKET_QR_CODE = "https://pos.yeahka.com/leposweb/home/getOrderQrCode.do";
            O2O_PROXY = "https://o2o.yeahka.com/o2o_proxy/";
            AD_MESSAGE = "https://app.yeahka.com/leshua/adv/advInfo.do";
            UPLOAD_PIC_TO_WEB_SERVER = "https://pos.yeahka.com/o2o/upload/upload_img_new.do";
            QUERY_BIT_FLAG = "https://pos.yeahka.com";///o2o/pay/queryBitFlag.do";
            UPDATE_BIT_FLAG = "https://pos.yeahka.com";///o2o/pay/updateBitFlag.do";
            UPLOAD_HEAD = "https://pos.yeahka.com/o2o/pay/uploadHead.do";
            BASE_TPLUS0_URL = "https://mobilepos.yeahka.com";
            BASE_WEB_URL = "https://pos.yeahka.com";
            BASE_AD_URL = "https://app.yeahka.com";
            SCAN_CODE_PAY_BASEURL = "https://pos.yeahka.com";
            QUICKEN_LOANS_ROOT_PERSON_CREDIT_REPORT = "http://192.168.33.50:8090/yeahka-fastloan/loan/query_loan_status.do?";
            SWITCH_APP_BASE_URL = "https://www.yeahka.com";
            MERCHANT_DATA_LIMIT_HOST = "https://pos.yeahka.com";
            GENERAL_AD_HOST = "https://pos.yeahka.com";
            NOTICE_SYSNEWS_HOST = "https://pos.yeahka.com";
            ABOAT_LESHUA_IBEACON = "https://www.yeahka.com/wap/swiper/ibeacon.html";
            ABOAT_LESHUA_SHANGHUIBAO = "https://www.yeahka.com/wap/swiper/shanghuibao.html";
            MACH_PUBLISH_AD_URL = "https://pos.yeahka.com/leposweb/adv/index.do";
            MACH_AD_HIS_URL = "https://pos.yeahka.com/leposweb/adv/preview.do";
            LEPOS_HELP_CENTER = "https://mobilepos.yeahka.com/help_index_new.html";
            CREDITCARDREPAYMENT_README = "https://app.yeahka.com/creditcardrepayment/readme.html";
            GET_APK_CHANNEL_INFO = "https://pos.yeahka.com/leposweb";
            YEAHKA_WEB_HOST = "https://pos.yeahka.com";
            QPAY_HOST_PORT = "https://mobilepos.yeahka.com";
            break;

        case 2:
            LOGIN_SERVER_CGI = "https://lepospre2.yeahka.com/cgi-bin/lepos_login_proxy.cgi";
            TRANSACTION_SERVER_CGI = "https://lepospre2.yeahka.com/cgi-bin/lepos_proxy.cgi";
            CARD_TRANS_INFO_SERVER_CGI = "https://ykproxytest.yeahka.com/cgi-bin/leshua_config.cgi";
            CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://mobileykpaypre.yeahka.com/cgi-bin/ykpayquery.cgi";
            OLD_CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://ykproxytest.yeahka.com/cgi-bin/leshua_query.cgi";
            //                UPLOAD_FILE_SERVER_CGI = "http://61.141.235.66:45006/cgi-bin/lepos_upload_file.cgi";
            SMS_STORE_SERVER_CGI = "https://pospre.yeahka.com/posadmin/home/";
            UPDATE_SELECT_CONNCET_TYPE_CGI = "https://pospre.yeahka.com/leposweb/app/getMobileUseInfo.do";
            MICROFINANCE_UPLOAD_SIGN_SERVER_CGI = "https://pospre.yeahka.com/leposweb/credit/signpost.do";
            MICROFINANCE_UPLOAD_SIGN_RESULT_SERVER_CGI = "https://pospre.yeahka.com/leposweb/credit/signsuccess.do";
            MICROFINANCE_CHECK_CITY_SERVER_CGI = "https://pospre.yeahka.com/leposweb/credit/citycheck.do";
            AD_UPLOAD_PHOTO_SERVER_CGI = "https://pospre.yeahka.com/leposweb/adv/picpost.do";
            MACH_CHECK_AD_HIS_SERVER_CGI = "https://pospre.yeahka.com/leposweb/adv/checkpost.do";
            WECHAT_PAY_WEB_SERVER_CGI = "https://pospre.yeahka.com/leposweb/adv/checkpost.do";
            WECHAT_PAY_WEB_GET_FEE_RATE_SERVER_CGI = "https://pospre.yeahka.com/leposweb/mobile/getWXOpenInfo.do";
            WECHAT_PAY_WEB_CREATE_ORDER_SERVER_CGI = "https://pospre.yeahka.com/posadmin/home/getWXOrders.do";
            USER_LOGIN_AD_URL = "https://pospre.yeahka.com/leposweb/mobile/wei_ad.do";
            USER_OPEN_READ_CARD_URL = "https://pospre.yeahka.com/leposweb/mobile/get_switch.do";
            USERlOGIN_AD_DEFUAL_URL = "https://pospre.yeahka.com/leposweb/mobile/ad_weixin.do";
            TUITUI_UPLOAD_PHOTO_SERVER_CGI = "https://pospre.yeahka.com/recommend/home/picpost.do";
            TUITUI_CANCLE_WECHAT_SHARE_SERVER_CGI = "https://pospre.yeahka.com/recommend/home/updateweixin.do";
            QUERY_TUITUI_MSG_COUNT_SERVER_CGI = "https://pospre.yeahka.com/recommend/home/getRecommendWeiCount.do";
            QUERY_ALIPAY_TIP_DILOAG_SHOW_STATUE_SERVER_CGI = "https://pospre.yeahka.com/leposweb/app/checkRateDiscount.do";
            UPDATE_WECHAT_GOODS_TYPE_CGI = "https://pospre.yeahka.com/leposweb/home/update_product_type.do";
            LESHOU_MERCHANT_ID = "10101";
            QUERY_O2O_ORDER_COUNT_SERVER_CGI = "https://o2opre2s.yeahka.com/o2o/index/query_merchant_order.do";
            QUERY_TUITUI_TEXT_UPDATE_SERVER_CGI = "https://pospre.yeahka.com/recommend/home/checkNewContentVersion.do";
            BIND_O2O_USER_ORDER_INFO = "https://o2opre2s.yeahka.com/o2o/index/set_channel_id.do";
            QUERY_O2O_ORDER_INFO_SERVER_CGI = "https://o2opre2s.yeahka.com/o2o/index/deal_detail.do";
            LED_SERVER_CGI = "https://o2opre3.yeahka.com/cgi-bin/o2o_business3.cgi";// lucien
            GPRS_SERVER_CGI = "https://o2opre3.yeahka.com/cgi-bin/o2o_business.cgi";
            HONGBAO_SERVER_CGI = "https://o2opre3.yeahka.com/cgi-bin/o2o_business2.cgi";
            WISDOM_MALL_SERVER_CGI = "https://o2opre2s.yeahka.com/mall/app/";
            REGISTER_HOST = "o2opre.yeahka.com";
            REGISTER_PORT = 45026;
            REALNAME_PAYMENT_UPLOAD_IDCARD = "https://pospre.yeahka.com/leposweb/mobile/upload_img.do"; // Char
            REALNAME_PAYMENT_APPLICATION = "https://pospre.yeahka.com/leposweb/mobile/certpayapply.do";// add 2015-07-16 ????????
            REALNAME_PAYMENT_QUERY_APPLECATION_STATE = "https://pospre.yeahka.com/leposweb/mobile/certpaystatus.do";// add 2015-07-18 ?????
            // QUICKEN_LOANS_ROOT = "https://mobileykpaypre.yeahka.com/yeahka-fastloan";// add 2015-07-18 ????
            QUICKEN_LOANS_ROOT = "https://p2pre.yeahka.com/yeahka-fastloan";
            QUICKEN_LOANS_BASE = "https://p2pre.yeahka.com";
            ORDER_TICKET_QR_CODE = "https://pospre.yeahka.com/leposweb/home/getOrderQrCode.do";// add 2015-08-10 web?--?
            O2O_PROXY = "https://o2o.yeahka.com/o2o_proxy/";
            AD_MESSAGE = "https://pospre.yeahka.com/leshua/adv/advInfo.do";
            UPLOAD_PIC_TO_WEB_SERVER = "https://o2opre2s.yeahka.com/o2o/upload/upload_img_new.do";
            QUERY_BIT_FLAG = "https://o2opre2s.yeahka.com";///o2o/pay/queryBitFlag.do";
            UPDATE_BIT_FLAG = "https://o2opre2s.yeahka.com";///o2o/pay/updateBitFlag.do";
            UPLOAD_HEAD = "https://o2opre2s.yeahka.com/o2o/pay/uploadHead.do";
            BASE_TPLUS0_URL = "https://lepospre2.yeahka.com";
            BASE_WEB_URL = "https://pospre.yeahka.com";
            BASE_AD_URL = "https://pospre.yeahka.com";
            SCAN_CODE_PAY_BASEURL = "https://o2opre2s.yeahka.com";
            QUICKEN_LOANS_ROOT_PERSON_CREDIT_REPORT = "http://192.168.33.50:8090/yeahka-fastloan/loan/query_loan_status.do?";
            SWITCH_APP_BASE_URL = "https://www.yeahka.com";
            MERCHANT_DATA_LIMIT_HOST = "https://pospre.yeahka.com";
            GENERAL_AD_HOST = "https://pospre.yeahka.com";
            NOTICE_SYSNEWS_HOST = "https://pospre.yeahka.com";
            ABOAT_LESHUA_IBEACON = "https://www.yeahka.com/wap/swiper/ibeacon.html";
            ABOAT_LESHUA_SHANGHUIBAO = "https://www.yeahka.com/wap/swiper/shanghuibao.html";
            MACH_PUBLISH_AD_URL = "https://pos.yeahka.com/leposweb/adv/index.do";
            MACH_AD_HIS_URL = "https://pos.yeahka.com/leposweb/adv/preview.do";
            LEPOS_HELP_CENTER = "https://mobilepos.yeahka.com/help_index_new.html";
            CREDITCARDREPAYMENT_README = "https://app.yeahka.com/creditcardrepayment/readme.html";
            GET_APK_CHANNEL_INFO = "https://pospre.yeahka.com/leposweb";
            YEAHKA_WEB_HOST = "https://pospre.yeahka.com";
            QPAY_HOST_PORT = "https://lepospre2.yeahka.com";
            break;

        case 3:
            LOGIN_SERVER_CGI = "https://mobilepostest2.yeahka.com/cgi-bin/lepos_login_proxy.cgi";
            TRANSACTION_SERVER_CGI = "https://mobilepostest2.yeahka.com/cgi-bin/lepos_proxy.cgi";
            CARD_TRANS_INFO_SERVER_CGI = "https://mobiletest.yeahka.com/cgi-bin/leshua_config.cgi";
            CARD_TRANS_ORDER_QEURY_SERVER_CGI = "http://mobileykpay.yeahka.com:8077/cgi-bin/ykpayquery.cgi";
            OLD_CARD_TRANS_ORDER_QEURY_SERVER_CGI = "https://mobiletest.yeahka.com/cgi-bin/leshua_query.cgi";
            //                UPLOAD_FILE_SERVER_CGI = "http://mobilepos.yeahka.com:9080/cgi-bin/lepos_upload_file.cgi";
            SMS_STORE_SERVER_CGI = "https://postest2.yeahka.com/posadmin/home/";
            UPDATE_SELECT_CONNCET_TYPE_CGI = "https://postest2.yeahka.com/leposweb/app/getMobileUseInfo.do";
            MICROFINANCE_UPLOAD_SIGN_SERVER_CGI = "https://postest2.yeahka.com/leposweb/credit/signpost.do";
            MICROFINANCE_UPLOAD_SIGN_RESULT_SERVER_CGI = "https://postest2.yeahka.com/leposweb/credit/signsuccess.do";
            MICROFINANCE_CHECK_CITY_SERVER_CGI = "https://postest2.yeahka.com/leposweb/credit/citycheck.do";
            AD_UPLOAD_PHOTO_SERVER_CGI = "https://postest2.yeahka.com/leposweb/adv/picpost.do";
            MACH_CHECK_AD_HIS_SERVER_CGI = "https://postest2.yeahka.com/leposweb/adv/checkpost.do";
            WECHAT_PAY_WEB_GET_FEE_RATE_SERVER_CGI = "https://postest2.yeahka.com/leposweb/mobile/getWXOpenInfo.do";
            WECHAT_PAY_WEB_CREATE_ORDER_SERVER_CGI = "https://postest2.yeahka.com/posadmin/home/getWXOrders.do";
            USER_LOGIN_AD_URL = "https://postest2.yeahka.com/leposweb/mobile/wei_ad.do";
            USER_OPEN_READ_CARD_URL = "https://postest2.yeahka.com/leposweb/mobile/get_switch.do";
            USERlOGIN_AD_DEFUAL_URL = "https://postest2.yeahka.com/leposweb/mobile/ad_weixin.do";
            TUITUI_UPLOAD_PHOTO_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/picpost.do";
            TUITUI_CANCLE_WECHAT_SHARE_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/updateweixin.do";
            QUERY_TUITUI_MSG_COUNT_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/getRecommendWeiCount.do";
            QUERY_ALIPAY_TIP_DILOAG_SHOW_STATUE_SERVER_CGI = "https://postest2.yeahka.com/leposweb/app/checkRateDiscount.do";
            UPDATE_WECHAT_GOODS_TYPE_CGI = "https://postest2.yeahka.com/leposweb/home/update_product_type.do";
            LESHOU_MERCHANT_ID = "10001";
            QUERY_O2O_ORDER_COUNT_SERVER_CGI = "https://wxs.yeahka.com/o2o/index/query_merchant_order.do";
            QUERY_TUITUI_TEXT_UPDATE_SERVER_CGI = "https://postest2.yeahka.com/recommend/home/checkNewContentVersion.do";
            BIND_O2O_USER_ORDER_INFO = "https://wxs.yeahka.com/o2o/index/set_channel_id.do";
            QUERY_O2O_ORDER_INFO_SERVER_CGI = "https://wxs.yeahka.com/o2o/index/deal_detail.do";
            LED_SERVER_CGI = "https://o2odevtest.yeahka.com/cgi-bin/o2o_business3.cgi";// LUCIEN
            HONGBAO_SERVER_CGI = "https://o2odevtest.yeahka.com/cgi-bin/o2o_business2.cgi";
            GPRS_SERVER_CGI = "https://o2odevtest.yeahka.com/cgi-bin/o2o_business.cgi";
            WISDOM_MALL_SERVER_CGI = "https://wxs.yeahka.com/mall/app/";
            REGISTER_HOST = "o2otest.yeahka.com";
            REGISTER_PORT = 45063;
            REALNAME_PAYMENT_UPLOAD_IDCARD = "https://businesstest.yeahka.com/leposweb/mobile/upload_img.do"; // Char
            REALNAME_PAYMENT_APPLICATION = "https://businesstest.yeahka.com/leposweb/mobile/certpayapply.do";// add 2015-07-16 ????????
            REALNAME_PAYMENT_QUERY_APPLECATION_STATE = "https://businesstest.yeahka.com/leposweb/mobile/certpaystatus.do";// add 2015-07-18 ?????
            QUICKEN_LOANS_ROOT = "https://p2ptest.yeahka.com/yeahka-fastloan";
            //  QUICKEN_LOANS_ROOT = "http://113.108.69.130:43100/yeahka-fastloan";
            QUICKEN_LOANS_BASE = "https://p2ptest.yeahka.com";/*/static/H5/bindcard/search_card.html?*/
            O2O_PROXY = "https://o2o.yeahka.com/o2o_proxy/";
            AD_MESSAGE = "https://postest2.yeahka.com/leshua/adv/advInfo.do";
            UPLOAD_PIC_TO_WEB_SERVER = "https://wxs.yeahka.com/o2o/upload/upload_img_new.do";
            QUERY_BIT_FLAG = "https://wxs.yeahka.com/o2o/pay";///queryBitFlag.do";
            UPDATE_BIT_FLAG = "https://wxs.yeahka.com/o2o/pay";///updateBitFlag.do";
            UPLOAD_HEAD = "https://wxs.yeahka.com/o2o/pay/uploadHead.do";
            BASE_TPLUS0_URL = "https://mobilepostest2.yeahka.com";/*/cgi-bin/lepos_lepost0serverconfig.cgi*/
            BASE_WEB_URL = "https://businesstest.yeahka.com";/*/leposweb/home/getOrderQrCode.do*/
            BASE_AD_URL = "https://postest2.yeahka.com";/*/leshua/adv/advInfoList.do*/
            SCAN_CODE_PAY_BASEURL = "https://wxs.yeahka.com";/*/pay/getSignedQrCodeUrl.do*/
            QUICKEN_LOANS_ROOT_PERSON_CREDIT_REPORT = "https://p2ptest.yeahka.com/yeahka-fastloan/loan/query_loan_status.do?";
            SWITCH_APP_BASE_URL = "https://www.yeahka.com";/*/json/switch_app.json*/
            MERCHANT_DATA_LIMIT_HOST = "https://postest2.yeahka.com";/*/leposweb/level/query_all_data.do*/
            GENERAL_AD_HOST = "https://postest2.yeahka.com";/*/leposweb/activity/isShow.do*/
            NOTICE_SYSNEWS_HOST = "https://postest2.yeahka.com";/*/leposweb/activity/msg_list.do*/
            ABOAT_LESHUA_IBEACON = "https://www.yeahka.com/wap/swiper/ibeacon.html";
            ABOAT_LESHUA_SHANGHUIBAO = "https://www.yeahka.com/wap/swiper/shanghuibao.html";
            MACH_PUBLISH_AD_URL = "https://pos.yeahka.com/leposweb/adv/index.do";
            MACH_AD_HIS_URL = "https://pos.yeahka.com/leposweb/adv/preview.do";
            LEPOS_HELP_CENTER = "https://mobilepos.yeahka.com/help_index_new.html";
            CREDITCARDREPAYMENT_README = "https://app.yeahka.com/creditcardrepayment/readme.html";
            GET_APK_CHANNEL_INFO = "https://postest2.yeahka.com/leposweb";
            YEAHKA_WEB_HOST = "https://postest2.yeahka.com";
            QPAY_HOST_PORT = "https://mobilepostest2.yeahka.com";
            break;
        }
    }
}