|
@@ -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);
|
|
|
}
|