Pārlūkot izejas kodu

添加注册来源

zengjiebin 7 gadi atpakaļ
vecāks
revīzija
e13ae2d06d

+ 10 - 0
app/src/main/java/com/sheep/gamegroup/model/api/ApiService.java

@@ -1750,4 +1750,14 @@ public interface ApiService {
     Observable<BaseMessage> missionGetinfo(@Query("act") int act, @Query("state") int state);
 
 //---------------------------end 小绵羊3.4.10新增 -- app/mission 春节活动-------------------------------------
+//---------------------------start 小绵羊3.5.0新增 ---------------------------------------
+
+    /**
+     * 用户来源记录
+     * from_game_id,game_id,type 需传这几个参数
+     */
+    @POST("app/user/user_from")
+    Observable<BaseMessage> postUserForm(@Body JSONObject jsonObject);
+
+//---------------------------end 小绵羊3.5.0新增 ---------------------------------------
 }

+ 4 - 2
app/src/main/java/com/sheep/gamegroup/module/login/LoginAct.java

@@ -19,6 +19,7 @@ import com.sheep.gamegroup.module.login.fragments.SignUpFgt;
 import com.sheep.gamegroup.module.login.fragments.ValidCaptchaFgt;
 import com.sheep.gamegroup.greendao.download.Account;
 import com.sheep.gamegroup.module.login.fragments.WelcomeFgt;
+import com.sheep.gamegroup.util.ApiJSONUtil;
 import com.sheep.gamegroup.util.CertificationUtil;
 import com.sheep.gamegroup.util.Jump2View;
 import com.sheep.gamegroup.util.TestUtil;
@@ -101,7 +102,8 @@ public class LoginAct extends BaseUMActivity implements LoginController {
 //            Snackbar.make(getWindow().getDecorView(), "登录成功", Snackbar.LENGTH_SHORT).show();
         if (TextUtils.isEmpty(loginResult.getUser().getBirthday())
                 || loginResult.getUser().getBirthday().startsWith("000")) {
-            getUserInfo(platform, loginResult);
+            ApiJSONUtil.postUserForm();//3.5.0 by 曾杰斌,注:这里认为,没有设置过生日的用户都是新注册用户,需要记录注册来源,可能从网页注册的用户进来后,记录来源会有问题,但是现在只记录游戏用户,问题不是很大
+            getUserInfoFromUM(platform, loginResult);
         } else {
             goMain(loginResult);
         }
@@ -111,7 +113,7 @@ public class LoginAct extends BaseUMActivity implements LoginController {
         }
     }
 
-    private void getUserInfo(int platform, final LoginEntity entity) {
+    private void getUserInfoFromUM(int platform, final LoginEntity entity) {
         if (platform == LoginController.PLATFORM_QQ || platform == LoginController.PLATFORM_WX) {
             UMShareAPI.get(SheepApp.getInstance()).getPlatformInfo(this,
                     platform == LoginController.PLATFORM_QQ ? SHARE_MEDIA.QQ : SHARE_MEDIA.WEIXIN,

+ 50 - 0
app/src/main/java/com/sheep/gamegroup/util/ApiJSONUtil.java

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