Explorar o código

新增游戏运行中 激活满月欠费的验证

Administrator %!s(int64=2) %!d(string=hai) anos
pai
achega
db634f5095

+ 9 - 0
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/zedu/cocos/congming/app/organ/ArrearsEvent.java

@@ -5,6 +5,15 @@ public class ArrearsEvent {
 
     public String message;
 
+    /**
+     * 状态:欠费
+     */
+    public static int FAIL = 0;
+    /**
+     * 状态:不欠费
+     */
+    public static int SUCCESS = 1;
+
     public ArrearsEvent(OrganEntity organ) {
         this.organ = organ;
     }

+ 13 - 0
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/zedu/cocos/congming/app/organ/OrganClient.java

@@ -1,5 +1,9 @@
 package com.zedu.cocos.congming.app.organ;
 
+import com.zedu.cocos.congming.app.device.DeviceEntity;
+
+import java.util.Date;
+
 public interface OrganClient {
     /**
      * 机构登录
@@ -10,4 +14,13 @@ public interface OrganClient {
      * getArrearsStatus
      */
     void arrearsStatus(String key);
+
+    boolean isFullMoon(Date issuedDate);
+
+    /**
+     * 未满月 且验证过欠费的设备 重置验证欠费状态
+     * @param activate
+     * @param checkArrearsSuccess
+     */
+    void resetArrearsStatus(DeviceEntity.DeviceActivateEntity activate, Integer checkArrearsSuccess);
 }

+ 38 - 5
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/zedu/cocos/congming/app/organ/OrganClientZedu.java

@@ -5,12 +5,11 @@ import com.lzy.okgo.model.HttpParams;
 import com.lzy.okgo.model.Response;
 import com.zedu.cocos.congming.app.device.DeviceClient;
 import com.zedu.cocos.congming.app.device.DeviceClientZedu;
+import com.zedu.cocos.congming.app.device.DeviceEntity;
 import com.zedu.cocos.congming.app.time.TimeClient;
 import com.zedu.cocos.congming.app.time.TimeClientZedu;
-import com.zedu.core.global.ErrorEvent;
 import com.zedu.support.request.OkgoClient;
 import com.zedu.support.request.OkgoTask;
-import com.zedu.support.request.exception.OkgoException;
 import com.zedu.support.request.response.BaseResponse;
 import com.zedu.support.request.response.ResponseCode;
 import com.zedu.support.request.wrapper.RequestCallbackWrapper;
@@ -19,7 +18,8 @@ import org.androidannotations.annotations.Bean;
 import org.androidannotations.annotations.EBean;
 import org.androidannotations.annotations.sharedpreferences.Pref;
 
-import java.util.List;
+import java.util.Calendar;
+import java.util.Date;
 
 import static com.lzy.okgo.cache.CacheMode.REQUEST_FAILED_READ_CACHE;
 import static com.zedu.core.global.GlobalConstant.CACHE_YEAR_TIME;
@@ -81,9 +81,9 @@ public class OrganClientZedu extends OkgoTask implements OrganClient {
                 super.onResult(code, result, exception);
                 code = noSuccessResponse(exception, code);
                 if (code == ResponseCode.RES_SUCCESS) {
-                    if (result.data != null && result.data.isArrears != 1) {
+                    if (result.data != null && result.data.isArrears != ArrearsEvent.SUCCESS) {
                         //更新验证欠费状态为成功
-                        mOrganPrefs.checkArrearsSuccess().put(1);
+                        mOrganPrefs.checkArrearsSuccess().put(ArrearsEvent.SUCCESS);
                         mBus.post(new ArrearsEvent(result.data, "验证成功"));
                     } else {
                         mBus.post(new ArrearsEvent(result.data, "您当前已欠费!"));
@@ -100,5 +100,38 @@ public class OrganClientZedu extends OkgoTask implements OrganClient {
         }, REQUEST_FAILED_READ_CACHE, CACHE_YEAR_TIME);
     }
 
+    /**
+     * 判断是否满月了
+     *
+     * @param issuedDate
+     * @return
+     */
+    @Override
+    public boolean isFullMoon(Date issuedDate) {
+        //激活时间是否满了一个月,满了一个月则要进行是否欠费的验证
+        Calendar ct = Calendar.getInstance();
+        ct.setTime(issuedDate);
+        ct.add(Calendar.MONTH, +1);
+        //激活后一个月的时间如果 小于 当前时间
+        if (ct.getTime().compareTo(new Date()) == -1) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 未满月 且验证过欠费的设备 重置验证欠费状态
+     * @param activate
+     * @param checkArrearsSuccess
+     */
+    @Override
+    public void resetArrearsStatus(DeviceEntity.DeviceActivateEntity activate, Integer checkArrearsSuccess){
+        //未满月 且验证过欠费的设备 重置验证欠费状态
+        if (!isFullMoon(activate.issued) && checkArrearsSuccess != ArrearsEvent.FAIL) {
+            mOrganPrefs.checkArrearsSuccess().put(ArrearsEvent.FAIL);
+        }
+    }
+
 
 }

+ 1 - 2
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/zedu/cocos/congming/page/device/DeviceActivity.java

@@ -108,9 +108,8 @@ public class DeviceActivity extends ZeduFragmentActivity {
         appkey = mOrganPrefs.organKey().get();
         if (StringUtils.isEmpty(appkey) && StringUtils.isEmpty(mDevicePrefs.sn().get()) && !checkWifiIsEnable()) {
             gotoDeviceIDQr();
-        } else {
-            mOrganClient.login(appkey, LauncherActivity.androidId);
         }
+        mOrganClient.login(appkey, LauncherActivity.androidId);
     }
 
     @Subscribe(threadMode = ThreadMode.MAIN)

+ 3 - 25
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/com/zedu/cocos/congming/page/launcher/LauncherActivity.java

@@ -195,17 +195,15 @@ public class LauncherActivity extends BaseFragmentActivity {
                 }
 
                 //判断是否开始验证欠费情况
-                if (isFullMoon(activate.issued) && mOrganPrefs.checkArrearsSuccess().get() == 0) {
+                if (mOrganClient.isFullMoon(activate.issued) && mOrganPrefs.checkArrearsSuccess().get() == ArrearsEvent.FAIL) {
                     mOrganClient.arrearsStatus(mOrganPrefs.organKey().get());
                     return;
                 }
                 //未满月 且验证过欠费的设备 重置验证欠费状态
-                if (!isFullMoon(activate.issued) && mOrganPrefs.checkArrearsSuccess().get() != 0) {
-                    mOrganPrefs.checkArrearsSuccess().put(0);
-                }
+                mOrganClient.resetArrearsStatus(activate, mOrganPrefs.checkArrearsSuccess().get());
                 // 进入游戏页
                 SDKUtils.AppKey = mOrganPrefs.organKey().get();
-                ;
+
                 startAppActivity();
                 showToast(String.format("%s启动%s", item.appName, true ? "成功" : "失败"));
             } else {
@@ -238,26 +236,6 @@ public class LauncherActivity extends BaseFragmentActivity {
         }
     }
 
-
-    /**
-     * 判断是否满月了
-     *
-     * @param issuedDate
-     * @return
-     */
-    private static boolean isFullMoon(Date issuedDate) {
-        //激活时间是否满了一个月,满了一个月则要进行是否欠费的验证
-        Calendar ct = Calendar.getInstance();
-        ct.setTime(issuedDate);
-        ct.add(Calendar.MONTH, +1);
-        //激活后一个月的时间如果 小于 当前时间
-        if (ct.getTime().compareTo(new Date()) == -1) {
-            return true;
-        } else {
-            return false;
-        }
-    }
-
     Dialog dialog;
 
     /**

+ 12 - 15
build/jsb-link/frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java

@@ -24,16 +24,11 @@
  ****************************************************************************/
 package org.cocos2dx.javascript;
 
-import org.androidannotations.annotations.sharedpreferences.Pref;
-import org.androidannotations.api.sharedpreferences.IntPrefField;
 import org.cocos2dx.lib.Cocos2dxActivity;
 import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
-import org.java_websocket.server.WebSocketServer;
 
 import android.Manifest;
 import android.content.BroadcastReceiver;
-import android.content.ContentResolver;
-import android.content.ContentUris;
 import android.content.ContentValues;
 import android.content.Context;
 import android.content.IntentFilter;
@@ -54,14 +49,10 @@ import android.content.Intent;
 import android.content.res.Configuration;
 import android.os.Environment;
 import android.os.Parcelable;
-import android.os.Process;
-import android.provider.DocumentsContract;
 import android.provider.MediaStore;
 import android.util.Log;
-import android.util.SparseIntArray;
 import android.view.Gravity;
 import android.view.LayoutInflater;
-import android.view.Surface;
 import android.view.View;
 import android.view.WindowManager;
 import android.widget.FrameLayout;
@@ -77,19 +68,17 @@ import androidx.core.os.EnvironmentCompat;
 
 import com.lzy.okgo.cache.CacheEntity;
 import com.lzy.okgo.db.CacheManager;
-import com.lzy.okgo.model.HttpParams;
 import com.orhanobut.logger.Logger;
 import com.zedu.R;
-import com.zedu.cocos.congming.app.ZeduApp;
-import com.zedu.cocos.congming.app.daemon.DaemonCreater;
 import com.zedu.cocos.congming.app.device.DeviceEntity;
-import com.zedu.cocos.congming.app.device.DevicePrefs_;
+import com.zedu.cocos.congming.app.organ.ArrearsEvent;
+import com.zedu.cocos.congming.app.organ.OrganClientZedu;
+import com.zedu.cocos.congming.app.organ.OrganPrefs_;
 import com.zedu.cocos.congming.component.apk.ApkInfo;
 import com.zedu.cocos.congming.page.activate.ActivateActivity_;
 import com.zedu.cocos.congming.page.device.DeviceActivity_;
 import com.zedu.cocos.congming.page.launcher.LauncherActivity;
 import com.zedu.cocos.congming.page.launcher.LauncherActivity_;
-import com.zedu.support.request.OkgoClientCache;
 import com.zedu.support.request.response.BaseResponse;
 
 import java.io.File;
@@ -230,7 +219,15 @@ public class AppActivity extends Cocos2dxActivity {
                 Logger.d("跳转到ActivateActivity_");
                 ActivateActivity_.intent(this).packageName(item.packageName).start();
             } else if (activate.status == 1) {
-
+                //判断是否开始验证欠费情况
+                OrganPrefs_ mOrganPrefs = new OrganPrefs_(this);
+                OrganClientZedu mOrganClient = new OrganClientZedu();
+                if (mOrganClient.isFullMoon(activate.issued) && mOrganPrefs.checkArrearsSuccess().get() == ArrearsEvent.FAIL) {
+                    LauncherActivity_.intent(this).start();
+                    return;
+                }
+                //未满月 且验证过欠费的设备 重置验证欠费状态
+                mOrganClient.resetArrearsStatus(activate, mOrganPrefs.checkArrearsSuccess().get());
             } else {
                 Logger.d("激活错误 ActivateActivity_");
                 this.showToast(String.format("%s激活错误", item.appName));