|
|
@@ -2,6 +2,7 @@ package com.sheep.gamegroup.util;
|
|
|
|
|
|
|
|
|
import android.support.annotation.IntDef;
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sheep.gamegroup.model.entity.BaseMessage;
|
|
|
@@ -140,4 +141,53 @@ public class ApiJSONUtil {
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+ public static final int POST_USER_FORM_TYPE_GAME = 1;
|
|
|
+ //记录用户来源
|
|
|
+// from_game_id,game_id,type 需传这几个参数
|
|
|
+// UserFrom结构如下:
|
|
|
+// created_at: integer ($int64)
|
|
|
+// 创建时间
|
|
|
+// from_game_id: string
|
|
|
+// 来源游戏
|
|
|
+// game_id: string
|
|
|
+// 要玩的游戏
|
|
|
+// game_name: string
|
|
|
+// 要玩的游戏名称
|
|
|
+// id: integer ($int64)
|
|
|
+// invitation_code: string
|
|
|
+// 用户绵羊号
|
|
|
+// parent_code: string
|
|
|
+// 父绵羊号
|
|
|
+// type: integer ($int64)
|
|
|
+// 来源类型 1:游戏
|
|
|
+// user_id: integer ($int64)
|
|
|
+// 用户ID
|
|
|
+ public static void postUserForm(int type, String game_id, String from_game_id) {
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("type", type);
|
|
|
+ json.put("game_id", game_id);
|
|
|
+ json.put("from_game_id", from_game_id);
|
|
|
+ SheepApp.getInstance().getNetComponent().getApiService()
|
|
|
+ .postUserForm(json)
|
|
|
+ .subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.getInstance()) {
|
|
|
+ @Override
|
|
|
+ public void onError(BaseMessage baseMessage) {
|
|
|
+ LogUtil.logE(baseMessage.getErrorMsg() + " " + baseMessage.getMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onNext(BaseMessage baseMessage) {
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ //记录用户来源
|
|
|
+ public static void postUserForm() {
|
|
|
+ String gameId = ChannelContent.getInstance().getGameId();
|
|
|
+ String fromGameId = ChannelContent.getInstance().getFromGameId();
|
|
|
+ if(!TextUtils.isEmpty(gameId) && !TextUtils.isEmpty(fromGameId)) {
|
|
|
+ postUserForm(ApiJSONUtil.POST_USER_FORM_TYPE_GAME, gameId, fromGameId);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|