Browse Source

1、创建订单接口联调完成
2、支付对外参数整理

fluty 4 years ago
parent
commit
b52a80a09b

+ 23 - 59
app/src/main/java/com/funcheer/channel/sdk/MainActivity.java

@@ -111,7 +111,6 @@ public class MainActivity extends Activity implements View.OnClickListener {
 
     private void initUI() {
         findViewById(getResourceId("fq_login", "id")).setOnClickListener(this);
-        findViewById(getResourceId("fq_switch_account", "id")).setOnClickListener(this);
         findViewById(getResourceId("fq_logout", "id")).setOnClickListener(this);
         findViewById(getResourceId("fq_charge", "id")).setOnClickListener(this);
         findViewById(getResourceId("fq_report_data", "id")).setOnClickListener(this);
@@ -127,15 +126,6 @@ public class MainActivity extends Activity implements View.OnClickListener {
                 login();
                 break;
 
-            case R.id.fq_switch_account:
-                try {
-                    switch_account();
-                } catch (JSONException e) {
-                    e.printStackTrace();
-                }
-
-                break;
-
             case R.id.fq_logout:
                 logout();
                 break;
@@ -175,7 +165,6 @@ public class MainActivity extends Activity implements View.OnClickListener {
         });
     }
 
-
     private void login() {
         FqGame.login(MainActivity.this, new IResult<LoginInfo>() {
             @Override
@@ -200,24 +189,30 @@ public class MainActivity extends Activity implements View.OnClickListener {
             return;
         }
 
-        float price = Float.parseFloat(priceString);
-        FqLog.d(TAG,"price : "+price);
+        FqLog.i(TAG,"price : "+priceString);
         PaymentInfo paymentInfo = new PaymentInfo();
-        paymentInfo.setOrderAmount("1");            //订单金额           必须字段
-        paymentInfo.setSubject("1元宝");              //商品名             必须字段
-        paymentInfo.setCpBillNo("cp_order001");    //CP订单号           必须字段
-        paymentInfo.setServerId("1");               //区服ID             必须字段
-        paymentInfo.setExtraInfo("FqGameSdk");      //拓展信息            必须字段
-//        paymentInfo.setUid(uid);                    //登录时成功拿到的UID  必须字段
-//        paymentInfo.setRoleName("Hello");           //角色名             必须字段
-        paymentInfo.setRemark("remark");            //订单备注            非必须字段
-
-//        paymentInfo.setRoleLevel("5");              //角色等级            非必须字段
-//        paymentInfo.setRoleId("Role_001");          //订单备注            非必须字段
-//        paymentInfo.setPartyName("帮派");            //帮派               非必须字段
-//        paymentInfo.setServerName("区服名");         //区服名              非必须字段
-
-
+        //订单金额
+        paymentInfo.setPrice(priceString);
+        //CP订单号
+        paymentInfo.setCpOrderId("cpOrder002");
+        //区服ID String的形式带入,值为int类型字符串
+        paymentInfo.setServerId("1");
+        //拓展信息
+        paymentInfo.setExtralInfo("FqGameSdk");
+        //订单备注 透传信息
+        paymentInfo.setRemark("remark");
+        //商品ID,String类型
+        paymentInfo.setProductId("1");
+        //商品名称
+        paymentInfo.setProductName("60金币");
+        //商品描述,值为String类型
+        paymentInfo.setProductDes("Fq");
+        //货币单位,值为String类型, 例:金币/钻石等且不可带量词
+        paymentInfo.setProductUnit("金币");
+        //兑换比例,String的形式带入,值为int类型,默认值为1
+        paymentInfo.setRate("1");
+        //计费ID 没有可不传
+        paymentInfo.setChargeId("pay123");
         FqGame.pay(MainActivity.this,paymentInfo, new IResult<String>() {
             @Override
             public void onSuccess(String s) {
@@ -264,12 +259,6 @@ public class MainActivity extends Activity implements View.OnClickListener {
         builder.show();
     }
 
-    private void dismissFloatView() {
-    }
-
-    private void showFloatView() {
-    }
-
     private void dataReport() {
         //get report data type
         String dataReportTypeString = ((EditText) findViewById(getResourceId("fq_report_type",
@@ -319,36 +308,11 @@ public class MainActivity extends Activity implements View.OnClickListener {
         staticsData.putString(ConstSet.DATA_KEY_ZONE_NAME, "阿狸一区");
         staticsData.putInt(ConstSet.DATA_KEY_DATA_TYPE, dataReportType);
         FqGame.setRoleInfo(staticsData);
-//        Idsfq.setExtraBundle(staticsData);
     }
 
     private void logout() {
     }
 
-    private void switch_account() throws JSONException {
-        HashMap hashMap = new HashMap<String, String>();
-        JSONObject custom = new JSONObject();
-        custom.put("ssoid", "ssoid");
-        custom.put("token", "token");
-        hashMap.put("channelType", "ansen");
-        hashMap.put("gameId", "123");
-        hashMap.put("imei", "123");
-        hashMap.put("channelId", "123");
-        hashMap.put("channelParams", custom.toString());
-
-        HttpManager.getInstance().post("http://192.168.1.152:9099/api/sdk/channel/v1/login", hashMap, new BaseCallback<String>() {
-            @Override
-            public void onFailure(BaseException msg) {
-                Log.i(TAG, "onFailure: ");
-            }
-
-            @Override
-            public void onSuccess(int code, String msg, String data) {
-                Log.i(TAG, "onResponse: " + data);
-            }
-        });
-    }
-
     private void showResult(String message) {
         Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
     }

+ 0 - 7
app/src/main/res/layout/fq_activity_main.xml

@@ -40,13 +40,6 @@
                     android:layout_height="wrap_content"
                     android:text="@string/fq_login" />
 
-                <Button
-                    android:id="@+id/fq_switch_account"
-                    android:layout_marginTop="5dp"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:text="@string/fq_switch_account" />
-
                 <Button
                     android:id="@+id/fq_logout"
                     android:layout_marginTop="5dp"

+ 0 - 9
app/src/main/res/values/lingdo_styles.xml

@@ -1,9 +0,0 @@
-<resources>
-
-    <!-- Base application theme. -->
-    <style name="lingdo_AppTheme" parent="@android:style/Theme.NoTitleBar">
-        <item name="android:windowIsTranslucent">false</item>
-        <item name="android:windowDisablePreview">true</item>
-    </style>
-
-</resources>

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -1,5 +1,5 @@
 <resources>
-    <string name="app_name">FQChannelMubao</string>
+    <string name="app_name">FQChannel-OPPO</string>
     <string name="fq_result">result...</string>
 
     <string name="fq_user">用户</string>

+ 52 - 45
fq_channel_oppo/src/main/java/com/fq/channel/sdk/SdkPluginOppo.java

@@ -11,18 +11,22 @@ import android.os.Looper;
 import android.util.Log;
 import android.widget.Toast;
 
+import com.fq.channel.sdk.base.constants.ConstSet;
 import com.fq.channel.sdk.base.constants.FqConfig;
 import com.fq.channel.sdk.base.interfaces.FQPluginApi;
 import com.fq.channel.sdk.base.interfaces.PluginResult;
 import com.fq.channel.sdk.base.interfaces.PluginResultHandler;
 import com.fq.channel.sdk.base.utils.FqLog;
+import com.fq.threelib.gson.Gson;
+import com.fq.threelib.gson.JsonObject;
 import com.nearme.game.sdk.GameCenterSDK;
 import com.nearme.game.sdk.callback.ApiCallback;
 import com.nearme.game.sdk.callback.GameExitCallback;
+import com.nearme.game.sdk.common.model.biz.PayInfo;
 import com.nearme.game.sdk.common.model.biz.ReportUserGameInfoParam;
+import com.nearme.platform.opensdk.pay.PayResponse;
 
 import org.json.JSONException;
-import org.json.JSONObject;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -66,20 +70,12 @@ public class SdkPluginOppo extends FQPluginApi {
                     @Override
                     public void onSuccess(String resultMsg) {
                         FqLog.i(TAG, "doGetTokenAndSsoid->onSuccess: " + resultMsg);
-                        try {
-                            JSONObject json = new JSONObject(resultMsg);
-                            JSONObject result = new JSONObject();
-                            result.put("ssoid",json.getString("ssoid"));
-                            result.put("token",json.getString("token"));
-
-                            HashMap<String, String> loginAuthData = new HashMap<>();
-                            loginAuthData.put("channelType","oppo");
-                            loginAuthData.put("channelParams",result.toString());
-                            loginFqSdkSuccess(handler,loginAuthData);
-
-                        } catch (JSONException e) {
-                            loginFqSdkError(handler, e.getMessage());
-                        }
+                        JsonObject json = new Gson().fromJson(resultMsg, JsonObject.class);
+                        JsonObject result = new JsonObject();
+                        result.add("ssoid", json.get("ssoid"));
+                        result.add("token", json.get("token"));
+
+                        loginFqSdkSuccess(handler, "oppo", result);
                     }
 
                     @Override
@@ -101,33 +97,40 @@ public class SdkPluginOppo extends FQPluginApi {
                     final PluginResultHandler handler) {
         FqLog.i(TAG, "pay map:" + (map != null ? map.toString() : ""));
 
-//        final PayInfo payInfo = new PayInfo(
-//                orderId + "",
-//                orderId + "__" + game_id + "__" + paramType, price * 100); //分为单位,转换成为元
-//        payInfo.setProductDesc(productDes);
-//        payInfo.setProductName(productName);
-//        payInfo.setCallbackUrl("");
-//        GameCenterSDK.getInstance().doPay(context, payInfo, new ApiCallback() {
-//
-//            @Override
-//            public void onSuccess(String resultMsg) {
-//                FqLog.i(TAG, "onSuccess");
-//                if (handler != null) {
-//                    payFqSdkSuccess(handler);
-//                }
-//            }
-//
-//            @Override
-//            public void onFailure(String resultMsg, int resultCode) {
-//                FqLog.i(TAG, "onFailure:"+resultMsg);
-//                if (PayResponse.CODE_CANCEL != resultCode) {
-//                    payFqSdkError(handler);
-//                } else {
-//                    // 取消支付处理
-//                    payFqSdkCancel(handler);
-//                }
-//            }
-//        });
+        String orderId = String.valueOf(map.get(ConstSet.PAY_ORDER_ID));
+        String extral = String.valueOf(map.get(ConstSet.PAY_EXTRAL_INFO));
+        float price = Float.valueOf((String) map.get(ConstSet.PAY_PRICE));
+        String productName = String.valueOf(map.get(ConstSet.PAY_PRODUCT_NAME));
+        String productDes = String.valueOf(map.get(ConstSet.PAY_PRODUCT_DES));
+        String notifyUrl = String.valueOf(map.get(ConstSet.PAY_NOTIFY_URl));
+
+        final PayInfo payInfo = new PayInfo(
+                orderId + "",
+                "oppo支付", 1); //分为单位,转换成为元
+        payInfo.setProductDesc(productDes);
+        payInfo.setProductName(productName);
+        payInfo.setCallbackUrl(notifyUrl);
+        FqLog.i(TAG, "pay notifyUrl:" + notifyUrl);
+        GameCenterSDK.getInstance().doPay(context, payInfo, new ApiCallback() {
+
+            @Override
+            public void onSuccess(String resultMsg) {
+                FqLog.i(TAG, "onSuccess");
+                if (handler != null) {
+                    payFqSdkSuccess(handler);
+                }
+            }
+
+            @Override
+            public void onFailure(String resultMsg, int resultCode) {
+                FqLog.i(TAG, "onFailure:" + resultMsg);
+                if (PayResponse.CODE_CANCEL == resultCode) {
+                    payFqSdkCancel(handler);
+                } else {
+                    payFqSdkError(handler);
+                }
+            }
+        });
     }
 
     /**
@@ -136,7 +139,7 @@ public class SdkPluginOppo extends FQPluginApi {
      * @param context
      * @param prh
      */
-    public void exit(Context context,final PluginResultHandler prh) {
+    public void exit(Context context, final PluginResultHandler prh) {
         FqLog.i(TAG, "exit");
         GameCenterSDK.getInstance().onExit((Activity) context, new GameExitCallback() {
 
@@ -293,8 +296,8 @@ public class SdkPluginOppo extends FQPluginApi {
         switch (dataType) {
             //这个在登入的时候调用
             case 3:
-                FqLog.i(TAG, "setExtraBundle: roleId:"+roleId+",roleName:"+roleName+",roleLevel:"+roleLevel+",serverId:"+serverId+",serverName:"+serverName+",chapter:Idreamsky");
-                GameCenterSDK.getInstance().doReportUserGameInfoData(new ReportUserGameInfoParam(roleId,roleName,Integer.valueOf(roleLevel),serverId,serverName,"Idreamsky",new HashMap<String, Number>()), new ApiCallback() {
+                FqLog.i(TAG, "setExtraBundle: roleId:" + roleId + ",roleName:" + roleName + ",roleLevel:" + roleLevel + ",serverId:" + serverId + ",serverName:" + serverName + ",chapter:Idreamsky");
+                GameCenterSDK.getInstance().doReportUserGameInfoData(new ReportUserGameInfoParam(roleId, roleName, Integer.valueOf(roleLevel), serverId, serverName, "Idreamsky", new HashMap<String, Number>()), new ApiCallback() {
 
                     @Override
                     public void onSuccess(String resultMsg) {
@@ -318,6 +321,10 @@ public class SdkPluginOppo extends FQPluginApi {
 
     }
 
+    @Override
+    public int getPayId() {
+        return 4;
+    }
 
     /**
      * 释放资源时调用,当用户退出界面或者游戏的时候,

+ 93 - 98
fq_plugin_api/src/main/java/com/fq/channel/sdk/api/bean/PaymentInfo.java

@@ -12,154 +12,149 @@ import com.fq.channel.sdk.base.utils.Utils;
 
 public class PaymentInfo {
 
+
     /**
-     * 必须字段
+     * 订单号
      */
-    //订单金额
-    private String orderAmount;
-
-    //商品名称
-    private String subject;
-//    private String subject = Utils.getString(Utils.getIdentifier("default_subject","string"));
-
-    //角色名
-    private String roleName;
-
-    //cp订单号
-    private String cpBillNo;
-
-    //用户在凤起平台的唯一标识
-    private String uid;
-
-    //区服id
-    private String serverId;
-
-    //拓展信息
-    private String extraInfo;
-
-
+    private String cpOrderId = "cpOrderId" ;
     /**
-     * 非必须字段
+     * 商品价格。
      */
-    //订单备注
-    private String remark;
-
-    //角色等级
-    private String roleLevel;
-
-    //角色id
-    private String roleId;
-
-    //帮派、工会名
-    private String partyName;
-
-    //区服名
-    private String serverName;
-
-    //Td_AppId
-    private String tdAppId;
-
-    public String getOrderAmount() {
-        return orderAmount;
-    }
-
-    public void setOrderAmount(String orderAmount) {
-        this.orderAmount = orderAmount;
-    }
+    private String price = "price" ;
+    /**
+     * 商品ID.
+     */
+    private String productId = "productId" ;
+    /**
+     * 商品名称
+     */
+    private String productName = "productName" ;
+    /**
+     * 商品描述
+     */
+    private String productDes = "productDes" ;
+    /**
+     * 商品单位,例如金币,钻石。
+     */
+    private String productUnit = "productUnit" ;
+    /**
+     * 服务器Id
+     */
+    private String serverId = "serverId" ;
+    /**
+     * 拓展字段
+     */
+    private String extralInfo = "extralInfo" ;
+    /**
+     * 商品量词,例:一张/一个
+     */
+    private String quantifier = "quantifier" ;
+    /**
+     * 兑换比例。
+     */
+    private String rate = "rate" ;
+    /**
+     * 计费ID
+     */
+    private String chargeId = "chargeId" ;
+    /**
+     * 透传字段
+     */
+    private String remark = "remark" ;
 
-    public String getSubject() {
-        return subject;
+    public String getRemark() {
+        return remark;
     }
 
-    public void setSubject(String subject) {
-        this.subject = subject;
+    public void setRemark(String remark) {
+        this.remark = remark;
     }
 
-    public String getRoleName() {
-        return roleName;
+    public String getCpOrderId() {
+        return cpOrderId;
     }
 
-    public void setRoleName(String roleName) {
-        this.roleName = roleName;
+    public void setCpOrderId(String cpOrderId) {
+        this.cpOrderId = cpOrderId;
     }
 
-    public String getCpBillNo() {
-        return cpBillNo;
+    public String getPrice() {
+        return price;
     }
 
-    public void setCpBillNo(String cpBillNo) {
-        this.cpBillNo = cpBillNo;
+    public void setPrice(String price) {
+        this.price = price;
     }
 
-    public String getUid() {
-        return uid;
+    public String getProductId() {
+        return productId;
     }
 
-    public void setUid(String uid) {
-        this.uid = uid;
+    public void setProductId(String productId) {
+        this.productId = productId;
     }
 
-    public String getServerId() {
-        return serverId;
+    public String getProductName() {
+        return productName;
     }
 
-    public void setServerId(String serverId) {
-        this.serverId = serverId;
+    public void setProductName(String productName) {
+        this.productName = productName;
     }
 
-    public String getExtraInfo() {
-        return extraInfo;
+    public String getProductDes() {
+        return productDes;
     }
 
-    public void setExtraInfo(String extraInfo) {
-        this.extraInfo = extraInfo;
+    public void setProductDes(String productDes) {
+        this.productDes = productDes;
     }
 
-    public String getRemark() {
-        return remark;
+    public String getProductUnit() {
+        return productUnit;
     }
 
-    public void setRemark(String remark) {
-        this.remark = remark;
+    public void setProductUnit(String productUnit) {
+        this.productUnit = productUnit;
     }
 
-    public String getRoleLevel() {
-        return roleLevel;
+    public String getServerId() {
+        return serverId;
     }
 
-    public void setRoleLevel(String roleLevel) {
-        this.roleLevel = roleLevel;
+    public void setServerId(String serverId) {
+        this.serverId = serverId;
     }
 
-    public String getRoleId() {
-        return roleId;
+    public String getExtralInfo() {
+        return extralInfo;
     }
 
-    public void setRoleId(String roleId) {
-        this.roleId = roleId;
+    public void setExtralInfo(String extralInfo) {
+        this.extralInfo = extralInfo;
     }
 
-    public String getPartyName() {
-        return partyName;
+    public String getQuantifier() {
+        return quantifier;
     }
 
-    public void setPartyName(String partyName) {
-        this.partyName = partyName;
+    public void setQuantifier(String quantifier) {
+        this.quantifier = quantifier;
     }
 
-    public String getServerName() {
-        return serverName;
+    public String getRate() {
+        return rate;
     }
 
-    public void setServerName(String serverName) {
-        this.serverName = serverName;
+    public void setRate(String rate) {
+        this.rate = rate;
     }
 
-    public String getTdAppId() {
-        return tdAppId;
+    public String getChargeId() {
+        return chargeId;
     }
 
-    public void setTdAppId(String tdAppId) {
-        this.tdAppId = tdAppId;
+    public void setChargeId(String chargeId) {
+        this.chargeId = chargeId;
     }
 }

+ 1 - 1
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/constants/AppConfig.java

@@ -104,7 +104,7 @@ public class AppConfig {
     /**
      * Td_AD_Tdid
      */
-    public static String sTdADTdid = "";
+    public static String sTdADTdid = FqConfig.get().getAdId();
 
     /**
      * Mac

+ 32 - 27
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/constants/ConstSet.java

@@ -8,58 +8,63 @@ package com.fq.channel.sdk.base.constants;
 public class ConstSet {
 
     /*支付常量集合*/
-    public static final String PAY_ORDER_ID = "orderId" ;
-    public static final String PAY_PAYMENT_STATE = "paymentstate" ;
-    public static final String PAY_PAYMETHOD = "paymethod" ;
-    public static final String PAY_SUBMIT_TIME = "submitTime" ;
     /**
-     * SDK的商品ID.
+     * CP 订单号
+     */
+    public static final String PAY_ORDER_CP = "cpOrderId" ;
+    /**
+     * 订单号
      */
-    public static final String PAY_PRODUCT_ID = "product_id" ;
+    public static final String PAY_ORDER_ID = "orderId" ;
     /**
      * 商品价格。
      */
-    public static final String PAY_PRICE = "wapMoney" ;
-    public static final String PAY_PRODUCT_NAME = "productName" ;
-    public static final String PAY_SERVER_ID = "serverId" ;
-    public static final String PAY_EXTRAL_INFO = "extral_info" ;
+    public static final String PAY_PRICE = "price" ;
     /**
-     * 商品描述
+     * 回调地址
      */
-    public static final String PAY_PRODUCT_DES = "product_des" ;
+    public static final String PAY_NOTIFY_URl = "notifyUrl" ;
     /**
-     * 商品数量。
+     * 商品ID.
      */
-    public static final String PAY_AMOUNT = "amount" ;
+    public static final String PAY_PRODUCT_ID = "productId" ;
     /**
-     * 商品量词,例:一张/一个
+     * 商品名称
      */
-    public static final String PAY_QUANTIFIER = "quantifier" ;
+    public static final String PAY_PRODUCT_NAME = "productName" ;
     /**
-     * 兑换比例。
+     * 商品描述
      */
-    public static final String PAY_RATE = "rate" ;
-    public static final String PAY_NOTIFYURl = "notifyurl" ;
+    public static final String PAY_PRODUCT_DES = "productDes" ;
     /**
      * 商品单位,例如金币,钻石。
      */
-    public static final String PAY_MONETARYUNIT = "monetaryunit" ;
+    public static final String PAY_PRODUCT_UNIT = "productUnit" ;
     /**
-     * 角色ID int类型字符串
+     * 服务器Id
      */
-    public static final String PAY_SERVER_UID = "server_uid" ;
+    public static final String PAY_SERVER_ID = "serverId" ;
     /**
-     * 渠道支付额外参数 例如 回调地址(NotifyUrl)、支付签名(Sign)等  由服务端返回
+     * 拓展字段
      */
-    public static final String PAY_CHANNEL_ORDERINFO = "Channel_Orderinfo" ;
+    public static final String PAY_EXTRAL_INFO = "extralInfo" ;
     /**
-     * 商品ID。
+     * 商品量词,例:一张/一个
      */
-    public static final String PAY_GOODS_ID = "goods_id" ;
+    public static final String PAY_QUANTIFIER = "quantifier" ;
+    /**
+     * 兑换比例。
+     */
+    public static final String PAY_RATE = "rate" ;
     /**
      * 计费ID
      */
-    public static final String PAY_CHARGE_ID = "charge_id" ;
+    public static final String PAY_CHARGE_ID = "chargeId" ;
+    /**
+     * 透传字段
+     */
+    public static final String PAY_REMARK = "remark" ;
+
 
     /*数据上报常量集合*/
     public static final String DATA_KEY_ROLE_NAME = "roleName" ;

+ 4 - 2
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/constants/FqConfig.java

@@ -35,10 +35,12 @@ public class FqConfig {
 
     public static final String KEY_UID = "uid";
 
+    public static final String KEY_TOKEN = "token";
+
     public static final String KEY_DEBUG = "isDebug";
 
 
-    private static final String BASE_URL = "http://ta.funcheergame.com";  //测试环境
+    public static final String BASE_URL = "http://ta.funcheergame.com";  //测试环境
 //    private static final String BASE_URL = "https://app.funcheergame.com";  //正试环境
 //    private static final String BASE_URL = "http://192.168.1.152:9099";  //本地环境
 
@@ -51,7 +53,7 @@ public class FqConfig {
      * api/third/oppo/v1/login
      * api/sdk/channel/v1/login
      */
-    public static String KEY_URL_LOGIN = BASE_URL + "/api/third/oppo/v1/login";//
+    public static String KEY_URL_LOGIN = BASE_URL + "/api/sdk/channel/v1/login";
     /**
      * 创建订单
      */

+ 12 - 2
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/interfaces/FQPluginApi.java

@@ -5,6 +5,8 @@ import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 
+import com.fq.threelib.gson.JsonObject;
+
 import java.util.HashMap;
 import java.util.Map;
 
@@ -57,7 +59,12 @@ public abstract class FQPluginApi {
      * @param data
      */
     public abstract void setRoleInfo(Bundle data);
-
+    /**
+     * 返回支付ID
+     * 默认0 风起支付
+     * @return payId
+     */
+    public abstract int getPayId();
     /**
      * 获取权限结果
      * @param requestCode
@@ -97,8 +104,11 @@ public abstract class FQPluginApi {
         }
     }
 
-    public void loginFqSdkSuccess(PluginResultHandler cb, HashMap<String, String> loginAuthData ) {
+    public void loginFqSdkSuccess(PluginResultHandler cb, String channelType, JsonObject channelParams ) {
         if (cb != null) {
+            HashMap<String, String> loginAuthData = new HashMap<>();
+            loginAuthData.put("channelType", channelType);
+            loginAuthData.put("channelParams", channelParams.toString());
             cb.onHandlePluginResult(new PluginResult(
                     PluginResult.Status.OK, loginAuthData));
         }

+ 9 - 3
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/net/FqNetRequest.java

@@ -4,6 +4,7 @@ import com.fq.channel.sdk.base.constants.FqConfig;
 import com.fq.channel.sdk.base.net.callback.BaseCallback;
 import com.fq.channel.sdk.base.net.req.ParamsUtils;
 import com.fq.channel.sdk.base.net.req.RepOrderBody;
+import com.fq.channel.sdk.base.utils.FqLog;
 import com.fq.channel.sdk.base.utils.Utils;
 
 import java.io.UnsupportedEncodingException;
@@ -16,6 +17,7 @@ import java.util.HashMap;
  * @CreateDate: 2020/4/3 10:45
  */
 public class FqNetRequest {
+    private static final String TAG = "FqNetRequest";
 
     /**
      * 初始化
@@ -24,7 +26,8 @@ public class FqNetRequest {
      */
     public static void init(BaseCallback callback) {
         String request = ParamsUtils.getInstance().generateInitParams();
-        HttpManager.getInstance().post(FqConfig.KEY_URL_INT,Utils.decodeText(request) , callback);
+        FqLog.i(TAG, "init:" + request);
+        HttpManager.getInstance().post(FqConfig.KEY_URL_INT, Utils.decodeText(request), callback);
     }
 
     /**
@@ -35,7 +38,9 @@ public class FqNetRequest {
      */
     public static void login(HashMap<String, String> channelInfo, BaseCallback callback) {
         String request = ParamsUtils.getInstance().generateLoginParams(channelInfo);
-        HttpManager.getInstance().post(FqConfig.KEY_URL_LOGIN,Utils.decodeText(request) , callback);
+        FqLog.i(TAG, "login:" + request);
+//        TODO  Utils.decodeText(request)
+        HttpManager.getInstance().post(FqConfig.KEY_URL_LOGIN, request, callback);
     }
 
     /**
@@ -45,7 +50,8 @@ public class FqNetRequest {
      */
     public static void createOrder(RepOrderBody payInfo, BaseCallback callback) {
         String request = ParamsUtils.getInstance().generateOrderParams(payInfo);
-        HttpManager.getInstance().post(FqConfig.KEY_URL_CREATE_ORDER,Utils.decodeText(request) , callback);
+        FqLog.i(TAG, "login:" + request);
+        HttpManager.getInstance().post(FqConfig.KEY_URL_CREATE_ORDER, Utils.decodeText(request), callback);
     }
 
 }

+ 2 - 1
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/net/callback/BaseCallback.java

@@ -35,7 +35,7 @@ public abstract class BaseCallback<T> implements Callback {
     public void onResponse(Call call, Response response) throws IOException {
         String body = response.body().string();
         if (response.isSuccessful()){
-            FqLog.i(TAG, "请求成功:" + "i=" +body );
+            FqLog.i(TAG, "请求成功:i=" +body );
             try {
                 JSONObject jsonObject = new JSONObject(body);
                 String head = jsonObject.optString(HttpConstant.KEY_RESPONSE_HEAD);
@@ -43,6 +43,7 @@ public abstract class BaseCallback<T> implements Callback {
                 if (resultHeader!=null&&resultHeader.getResponseCode().equals("00000")){
                     successParseJson(jsonObject.optString(HttpConstant.KEY_RESPONSE_BODY));
                 }else {
+                    FqLog.i(TAG, "onFailure:" + "i=" +resultHeader.getResponseMsg() );
                     onFailure(new BaseException(HttpConstant.HTTP_NET_ERROR,resultHeader.getResponseMsg()));
                 }
             } catch (Exception e) {

+ 14 - 4
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/net/req/ParamsUtils.java

@@ -6,10 +6,13 @@ import com.fq.channel.sdk.base.exception.NullStringToEmptyAdapterFactory;
 import com.fq.channel.sdk.base.utils.DES;
 import com.fq.channel.sdk.base.utils.DeviceUtils;
 import com.fq.channel.sdk.base.utils.EncryptUtils;
+import com.fq.channel.sdk.base.utils.FqLog;
 import com.fq.channel.sdk.base.utils.Utils;
 import com.fq.threelib.gson.Gson;
 import com.fq.threelib.gson.GsonBuilder;
+import com.fq.threelib.gson.JsonObject;
 
+import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.lang.reflect.Field;
@@ -19,6 +22,7 @@ import java.util.Iterator;
 import java.util.TreeMap;
 
 import static com.fq.channel.sdk.base.constants.FqConfig.KEY_CHANNEL_TYPE;
+import static com.fq.channel.sdk.base.constants.FqConfig.KEY_TOKEN;
 
 /**
  * Created by Ethan on 2017/7/5.
@@ -27,6 +31,8 @@ import static com.fq.channel.sdk.base.constants.FqConfig.KEY_CHANNEL_TYPE;
 
 public class ParamsUtils {
 
+    private static final String TAG = "ParamsUtils";
+
     private ParamsUtils() {
     }
 
@@ -73,15 +79,19 @@ public class ParamsUtils {
 
         ReqContent<RepLoginBody> reqContent = new ReqContent<>();
         //生成login对象
-        RepLoginBody body = new RepLoginBody();
+        RepLoginBody body = new RepLoginBody<JsonObject>();
         body.setAdid(FqConfig.get().getAdId());
         body.setChannelId(FqConfig.get().getChannelId());
         //缓存 渠道类型 , 创建订单使用
         String channelType = loginOauthInfo.get("channelType");
         FqConfig.get().put(KEY_CHANNEL_TYPE,channelType);
-
+        FqLog.i(TAG,"channelType : "+channelType);
+        String channelParams = loginOauthInfo.get("channelParams");
+        FqLog.i(TAG,"channelParams : "+channelParams);
+        JsonObject jsonObject =  new Gson().fromJson(channelParams, JsonObject.class);
         body.setChannelType(channelType);
-        body.setChannelParams(loginOauthInfo.get("channelParams"));
+        body.setChannelParams(jsonObject);
+
         //生成login 操作的head
         ReqHeader head = generateReqHeader(body);
         //转换成最终请求用的Json
@@ -136,7 +146,7 @@ public class ParamsUtils {
         reqHeader.setAdFlag(AppConfig.AD_FLAG); //广告名
         reqHeader.setSdkVersion(AppConfig.FQ_GAME_SDK_VERSION_CODE);//凤起SDK版本
         reqHeader.setGameVersion(AppConfig.GAME_VERSION);//游戏版本
-        reqHeader.setToken(AppConfig.sCurrentToken); //token
+        reqHeader.setToken(FqConfig.get().getString(KEY_TOKEN)); //token
 
         reqHeader.setTdid(AppConfig.sTdADTdid);//Tdid
 

+ 6 - 4
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/net/req/RepLoginBody.java

@@ -1,11 +1,13 @@
 package com.fq.channel.sdk.base.net.req;
 
+import org.json.JSONObject;
+
 /**
  * @Description: 渠道登录请求体
  * @Author: FLuty
  * @CreateDate: 2020/4/13 09:35
  */
-public class RepLoginBody{
+public class RepLoginBody<T>{
 
 
     /**
@@ -18,7 +20,7 @@ public class RepLoginBody{
     private String channelType;
     private String channelId;
     private String adid;
-    private String channelParams;
+    private T channelParams;
 
     public String getChannelType() {
         return channelType;
@@ -44,11 +46,11 @@ public class RepLoginBody{
         this.adid = adid;
     }
 
-    public String getChannelParams() {
+    public T getChannelParams() {
         return channelParams;
     }
 
-    public void setChannelParams(String channelParams) {
+    public void setChannelParams(T channelParams) {
         this.channelParams = channelParams;
     }
 }

+ 22 - 0
fq_plugin_base/src/main/java/com/fq/channel/sdk/base/utils/Utils.java

@@ -395,4 +395,26 @@ public class Utils {
         return false;
     }
 
+    /**
+     * 生成一个特殊13位标示
+     *
+     * @return
+     */
+    public static String generate13Label() {
+        StringBuilder sb = new StringBuilder();
+        String time = String.valueOf(System.currentTimeMillis());
+        int len = time.length();
+        if (len < 13) {
+            sb.append(time);
+            int suffixLen = 13 - len;
+            for (int i = 0; i < suffixLen; i++) {
+                sb.append(0);
+            }
+        } else if (len == 13) {
+            sb.append(time);
+        } else if (len > 13) {
+            sb.append(time.substring(len - 13));
+        }
+        return sb.toString();
+    }
 }

+ 2 - 1
fq_plugin_base/src/main/java/com/fq/threelib/okhttp3/internal/platform/Android10Platform.java

@@ -21,8 +21,9 @@ import java.util.List;
 import javax.annotation.Nullable;
 import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLSocket;
+
+import com.fq.threelib.animal_sniffer.IgnoreJRERequirement;
 import com.fq.threelib.okhttp3.Protocol;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
 
 /** Android 10+. */
 @SuppressLint("NewApi")

+ 53 - 41
fq_plugin_core/src/main/java/com/fq/channel/sdk/core/JointManager.java

@@ -2,13 +2,14 @@ package com.fq.channel.sdk.core;
 
 import android.content.Context;
 import android.os.Bundle;
+import android.text.TextUtils;
 
 import com.fq.channel.sdk.base.constants.FqConfig;
+import com.fq.channel.sdk.base.constants.ResourceCfg;
 import com.fq.channel.sdk.base.exception.BaseException;
 import com.fq.channel.sdk.base.interfaces.PluginResult;
+import com.fq.channel.sdk.base.interfaces.PluginResult.Status;
 import com.fq.channel.sdk.base.interfaces.PluginResultHandler;
-import com.fq.channel.sdk.base.constants.ResourceCfg;
-import com.fq.channel.sdk.base.interfaces.PluginResult.*;
 import com.fq.channel.sdk.base.net.FqNetRequest;
 import com.fq.channel.sdk.base.net.callback.BaseCallback;
 import com.fq.channel.sdk.base.net.req.RepOrderBody;
@@ -23,6 +24,8 @@ import org.json.JSONObject;
 import java.util.HashMap;
 import java.util.Map;
 
+import static com.fq.channel.sdk.base.constants.ConstSet.*;
+
 /**
  * @Description: 核心层对外API
  * @Author: FLuty
@@ -98,6 +101,7 @@ public class JointManager {
         FqNetRequest.login(channelInfo, new BaseCallback<ResultLoginBody>() {
             @Override
             public void onFailure(BaseException msg) {
+                FqLog.e(TAG, "createOrder onFailure:" + "i=" + msg.getMessage());
                 cb.onHandlePluginResult(new PluginResult(Status.ERROR, msg.getMsg()));
             }
 
@@ -106,11 +110,13 @@ public class JointManager {
                 try {
                     JSONObject jsonObject = new JSONObject();
                     String uid = data.getUid();
-                    //缓存Uid
-                    FqConfig.get().put(FqConfig.KEY_UID,uid);
+                    String token = data.getToken();
+                    //缓存Uid token
+                    FqConfig.get().put(FqConfig.KEY_UID, uid);
+                    FqConfig.get().put(FqConfig.KEY_TOKEN, token);
 
                     jsonObject.put("uid", uid);
-                    jsonObject.put("token", data.getToken());
+                    jsonObject.put("token", token);
 
                     cb.onHandlePluginResult(new PluginResult(Status.OK, jsonObject));
                 } catch (JSONException e) {
@@ -125,58 +131,64 @@ public class JointManager {
     }
 
     private void createOrder(final Context context, final Map map, final PluginResultHandler cb) {
-        RepOrderBody repOrderBody = new RepOrderBody();
-        repOrderBody.setChannelType( FqConfig.get().getString(FqConfig.KEY_CHANNEL_TYPE));
-        repOrderBody.setUid( FqConfig.get().getString(FqConfig.KEY_UID));
-        repOrderBody.setExtraInfo(getMapValus(map,"extraInfo"));
-        repOrderBody.setIsTest(FqConfig.DEBUG_VERSION?"1":"0");
-        repOrderBody.setOrderAmount(getMapValus(map,"orderAmount"));
-        repOrderBody.setOrderPlatform(getMapValus(map,"orderPlatform"));
-        repOrderBody.setOrderType(getMapValus(map,"orderType"));
-        repOrderBody.setRemark(getMapValus(map,"remark"));
-        repOrderBody.setSubject(getMapValus(map,"subject"));
-        data.getBundle("roleName");
-        data.getBundle("serverId");
-        repOrderBody.setRoleName(getMapValus(map,"roleName"));
-        repOrderBody.setServerId(getMapValus(map,"serverId"));
+        String cpOrderId = getMapValus(map, PAY_ORDER_CP);
+        String price = getMapValus(map, PAY_PRICE);
+        String productName = getMapValus(map, PAY_PRODUCT_NAME);
+        String serverId = getMapValus(map, PAY_SERVER_ID);
+        String extraInfo = getMapValus(map, PAY_EXTRAL_INFO);
+        String remark = getMapValus(map, PAY_REMARK);
 
+        RepOrderBody repOrderBody = new RepOrderBody();
+        repOrderBody.setCpBillNo(cpOrderId);
+        repOrderBody.setChannelType(FqConfig.get().getString(FqConfig.KEY_CHANNEL_TYPE));
+        repOrderBody.setUid(FqConfig.get().getString(FqConfig.KEY_UID));
+        repOrderBody.setExtraInfo(extraInfo);
+        repOrderBody.setIsTest("0");
+        repOrderBody.setOrderAmount(price);
+        repOrderBody.setOrderPlatform(ApiPlugin.getInstace().getPayId());
+        repOrderBody.setOrderType("6");
+        repOrderBody.setRemark(remark);
+        repOrderBody.setSubject(productName);
+        repOrderBody.setServerId(serverId);
+
+        if (data != null) {
+            String roleName = (String) data.get("roleName");
+            if (!TextUtils.isEmpty(roleName)) {
+                repOrderBody.setRoleName(roleName);
+            }
+        }
         FqNetRequest.createOrder(repOrderBody, new BaseCallback<ResultPayBody>() {
             @Override
             public void onFailure(BaseException msg) {
+                FqLog.e(TAG, "createOrder onFailure:" + "i=" + msg.getMessage());
                 cb.onHandlePluginResult(new PluginResult(Status.ERROR, msg.getMessage()));
             }
 
             @Override
             public void onSuccess(int code, String msg, ResultPayBody data) {
-
-//               startPay(context,data,cb);
+                FqLog.i(TAG, "createOrder : " + data.getOrderId() + " /NotifyUrl : " + data.getNotifyUrl());
+                map.put(PAY_ORDER_ID, data.getOrderId());
+                map.put(PAY_NOTIFY_URl, FqConfig.BASE_URL + "/" + data.getNotifyUrl());
+                ApiPlugin.getInstace().pay(context, map, new PluginResultHandler() {
+                    @Override
+                    public void onHandlePluginResult(PluginResult result) {
+                        if (result.getStatus() == Status.OK) {
+                            cb.onHandlePluginResult(new PluginResult(Status.OK, result.getMessage()));
+                        } else if (result.getStatus() == Status.CANCEL) {
+                            cb.onHandlePluginResult(new PluginResult(Status.CANCEL, result.getMessage()));
+                        } else {
+                            cb.onHandlePluginResult(new PluginResult(Status.ERROR, result.getMessage()));
+                        }
+                    }
+                });
             }
         });
     }
 
-    private String getMapValus(Map map,String key){
+    private String getMapValus(Map map, String key) {
         return String.valueOf(map.get(key));
     }
 
-//    private void startPay(Context context,ResultPayBody data, PluginResultHandler cb) {
-//        HashMap<Object, Object> payParams = new HashMap<Object, Object>();
-//        payParams.put(ConstSet.PAY_ORDER_ID, unolPay.getOrder_id());
-//        payParams.put(ConstSet.PAY_PAYMENT_STATE, 8);
-//        payParams.put(ConstSet.PAY_PAYMETHOD, paymethod);
-//        payParams.put(ConstSet.PAY_PRODUCT_DES, productDescription);
-//        payParams.put(ConstSet.PAY_PRICE, price);
-//        payParams.put(ConstSet.PAY_PRODUCT_NAME, productName);
-//        payParams.put(ConstSet.PAY_SERVER_ID, serverId);
-//        payParams.put(ConstSet.PAY_EXTRAL_INFO, extraInfo);
-//        payParams.put(ConstSet.PAY_PRODUCT_ID, id);
-//        payParams.put(ConstSet.PAY_AMOUNT, amount);
-//        payParams.put(ConstSet.PAY_RATE, rate);
-//        payParams.put(ConstSet.PAY_MONETARYUNIT, monetaryunit);
-//        payParams.put(ConstSet.PAY_CHARGE_ID, chargeId);
-//        payParams.put(ConstSet.PAY_GOODS_ID, goodsId);
-//        ApiPlugin.getInstace().pay(context, paymentInfo, cb);
-//    }
-
     public void exit(Context context, PluginResultHandler cb) {
         ApiPlugin.getInstace().exit(context, cb);
     }

+ 14 - 0
fq_plugin_core/src/main/java/com/fq/channel/sdk/core/invoke/ApiPlugin.java

@@ -120,6 +120,20 @@ public class ApiPlugin extends ApiReflectManager {
         }
     }
 
+    /**
+     * 获取支付ID
+     *
+     * */
+    public String getPayId() {
+        try {
+            Integer payMethod = (Integer) invoke(getDeclaredMethod("getPayId"));
+            return payMethod.toString();
+        } catch (NoSuchFunctionException e) {
+            FqLog.e(TAG, "====setApiCurrentContext====没有实现该函数");
+            return "0";
+        }
+    }
+
     public void onCreate(Bundle savedInstanceState) {
         try {
             invoke(getDeclaredMethod("onCreate" ,Bundle.class), savedInstanceState);