ソースを参照

打卡参数invitation_code直接使用用户信息中的邀请人的邀请码;优化打卡流程

zengjiebin 8 年 前
コミット
eef8b9d068

+ 4 - 4
app/src/main/java/com/kfzs/duanduan/fragment/FgtSmallSheep.java

@@ -229,15 +229,13 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
     }
 
 
-   public static String balance ="0";//余额(打卡界面需要用到余额来判断支付方式)//by div RN代码中需要用到,不知道怎么传过去,先这样吧
 
     private void refalsh() {
 
         if (myPrice == null || userEntity == null) {
             return;
         }
-        balance = userEntity.getBalance();
-        myPrice.setText(balance + " 元");
+        myPrice.setText(userEntity.getBalance() + " 元");
         myAllPrice.setText("累计资产 " + userEntity.getTotal_asset() + " 元");
         nameTv.setText(userEntity.getNickname() + "");//绵羊号:123456789
         sheepNumTv.setText("绵羊号:" + userEntity.getInvitation_code());
@@ -474,6 +472,8 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
         userEntity = JSON.parseObject(JSONObject.toJSONString(baseMessage.getData()), UserEntity.class);
         //保存用户id信息
         PreferenceUtils.setPrefString(SheepApp.mContext, UMConfigUtils.LOGIN_OPENID, userEntity.getOpen_id());
+        //保存用户邀请人邀请码
+        PreferenceUtils.setPrefString(SheepApp.mContext, "invitation_code", userEntity.getParent_code());
         //统计用户登录信息
         UMConfigUtils.onProfileSignIn();
         try {
@@ -916,7 +916,7 @@ public class FgtSmallSheep extends BaseCompatFragment implements SmallSheepContr
                         break;
                     case 9://打卡赚钱
                         showToast("打卡赚钱");
-                        Jump2View.getInstance().goSignCardAct(activity, balance);
+                        Jump2View.getInstance().goSignCardAct(activity, null);
                         break;
                     default:
                         G.showToast(R.string.coming_soon);

+ 17 - 0
app/src/main/java/com/kfzs/duanduan/utils/NumberFormatUtils.java

@@ -1,5 +1,7 @@
 package com.kfzs.duanduan.utils;
 
+import android.text.TextUtils;
+
 import java.math.BigDecimal;
 
 /**
@@ -42,4 +44,19 @@ public class NumberFormatUtils {
         double   f1   =   b.setScale(newScale,   BigDecimal.ROUND_HALF_UP).doubleValue();
         return f1;
     }
+
+    public static float parseFloat(String balance) {
+        return parseFloat(balance, 0f);
+    }
+
+    public static float parseFloat(String balance, float defaultValue) {
+        if(!TextUtils.isEmpty(balance)){
+            try {
+                return Float.parseFloat(balance);
+            } catch (NumberFormatException e) {
+                e.printStackTrace();
+            }
+        }
+        return defaultValue;
+    }
 }

+ 2 - 1
app/src/main/java/com/sheep/gamegroup/statistics/AppStatistics.java

@@ -8,6 +8,7 @@ import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.util.SheepSubscriber;
 import com.sheep.gamegroup.util.ChannelContent;
 import com.sheep.gamegroup.util.DeviceUtil;
+import com.sheep.gamegroup.util.PreferenceUtils;
 import com.sheep.jiuyan.samllsheep.SheepApp;
 import com.sheep.jiuyan.samllsheep.utils.SpUtils;
 
@@ -59,7 +60,7 @@ public class AppStatistics {
         jsonObject.put("type",type);
         jsonObject.put("subtype",subType);
         jsonObject.put("substring",subString);
-        jsonObject.put("invitation_code", ChannelContent.getInstance().getChannel_name());
+        jsonObject.put("invitation_code",  PreferenceUtils.getPrefString(SheepApp.mContext, "invitation_code", ""));
         apiService.appEventTracking(jsonObject).subscribeOn(Schedulers.io())
                 .observeOn(AndroidSchedulers.mainThread())
                 .subscribe(new SheepSubscriber<BaseMessage>(SheepApp.mContext) {

+ 3 - 1
app/src/main/java/com/sheep/gamegroup/util/ChannelContent.java

@@ -95,7 +95,9 @@ public class ChannelContent {
         }
         return hasChannelFile;
     }
-    private static final String[] defaultChannels = {"976873", "849198", "935404", "849198", "935404"};//, "25284360", "40253514", "38291072", "61337548"};
+    private static final String[] defaultChannels = {
+            "849198", "935404", "34176879", "38291072", "25284360","976873",
+            "849198", "935404", "34176879", "38291072", "25284360"};//, "40253514", "61337548"};
     public String getChannel_name() {
         if (TextUtils.isEmpty(channel_name)) {
             return defaultChannels[Math.abs(new Random().nextInt())%defaultChannels.length];

+ 1 - 1
app/src/main/java/com/sheep/gamegroup/util/CommonUtil.java

@@ -370,7 +370,7 @@ public class CommonUtil {
                 Jump2View.getInstance().goTryplayView(context, 1);
                 break;
             case 9://打卡赚钱
-                Jump2View.getInstance().goSignCardAct(context, FgtSmallSheep.balance);
+                Jump2View.getInstance().goSignCardAct(context, null);
                 break;
             case 98://内部WebView加载H5
                 Jump2View.getInstance().goWeb(context, entity.getUrl(), entity.getTitle());

+ 0 - 1
app/src/main/java/com/sheep/gamegroup/util/Jump2View.java

@@ -953,7 +953,6 @@ public class Jump2View {
      */
     public void goSignCardAct(Context context, Object o){
         Intent intent = new Intent(context, SignCardAct.class);
-        intent.putExtra("balance",o.toString());
         context.startActivity(intent);
         UMConfigUtils.Event.PUNCH.onEvent();
     }

+ 15 - 3
app/src/main/java/com/sheep/gamegroup/view/activity/SignCardAct.java

@@ -12,19 +12,23 @@ import android.widget.TextView;
 
 import com.kfzs.duanduan.event.BigEvent;
 import com.kfzs.duanduan.event.EventTypes;
+import com.kfzs.duanduan.utils.NumberFormatUtils;
 import com.sheep.gamegroup.absBase.BaseActivity;
 import com.sheep.gamegroup.di.components.DaggerSignCardComponent;
 import com.sheep.gamegroup.di.modules.SignCardModule;
 import com.sheep.gamegroup.model.entity.BaseMessage;
 import com.sheep.gamegroup.model.entity.DialogEntity;
 import com.sheep.gamegroup.model.entity.PunchAndSign;
+import com.sheep.gamegroup.model.entity.UserEntity;
 import com.sheep.gamegroup.presenter.SignCardContract;
 import com.sheep.gamegroup.presenter.SignCardPresenter;
 import com.sheep.gamegroup.util.Jump2View;
+import com.sheep.gamegroup.util.MyDbManager;
 import com.sheep.gamegroup.util.UMConfigUtils;
 import com.sheep.gamegroup.util.ViewUtil;
 import com.sheep.jiuyan.samllsheep.R;
 import com.sheep.jiuyan.samllsheep.SheepApp;
+import com.sheep.jiuyan.samllsheep.utils.G;
 import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;
 
 import org.greenrobot.eventbus.EventBus;
@@ -63,7 +67,6 @@ public class SignCardAct extends BaseActivity implements SignCardContract.View {
     @BindView(R.id.sign_tv_kf)
     TextView signTvKf;
 
-    String balance;
     private int punchType = 0;//打卡状态 //1未报名 2已打卡 3可以打卡 4已经过了时间 5活动暂未开始
 
 
@@ -75,7 +78,6 @@ public class SignCardAct extends BaseActivity implements SignCardContract.View {
     @Override
     public void initView() {
         activity = this;
-        balance = getIntent().getStringExtra("balance");
         TitleBarUtils
                 .getInstance()
                 .setTitle(activity, "每日打卡")
@@ -237,8 +239,18 @@ public class SignCardAct extends BaseActivity implements SignCardContract.View {
         }
     }
 
+    private UserEntity userEntity;
     private void trySignUp() {
-        if(Float.valueOf(balance) >= 1){
+        if(userEntity == null) {
+            try {
+                userEntity = MyDbManager.getInstance().dbFindUser();
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        if(userEntity == null || TextUtils.isEmpty(userEntity.getBalance())){
+            G.showToast(R.string.unknown_error);
+        } else if(NumberFormatUtils.parseFloat(userEntity.getBalance()) >= 1){
             UMConfigUtils.Event.PUNCH_PUNCH.onEvent();
             presenter.goSignUp();
         }else {

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

@@ -36,7 +36,7 @@
     <string name="accessibility_desc">小绵羊任务</string>
     <string name="sign_card_text">·每日<font color="red">00:00-23:59:00</font>之间支付<font color="red">1</font>元,即可有机会参与次日打卡活动;\n·次日早晨<font color="red">07:00-09:00</font>时间段参与打卡后,可平分前日奖金池内全部现金,
     打卡失败则不可参与当日奖金分配;\n·若当日无人参与打卡平分现金活动,则今日奖池金额累加到明日奖池中\n·每日平分金额于早9点后开始结算,系统将于12小时内发放到个人账户,因网络原因,部分用户
-    可能出现不及时到账的情况,可与我们客联系,感谢您的谅解。\n·本活动最终解释权归橙风有量科技有限公司所有.</string>
+    可能出现不及时到账的情况,可与我们客联系,感谢您的谅解。\n·本活动最终解释权归橙风有量科技有限公司所有.</string>
 
     <string name="sign_record_money">%s元</string>
     <string name="sign_record_item_money">打卡成功,获得奖励%s元</string>