zxy 4 anni fa
parent
commit
61663ba825

+ 3 - 2
app/build.gradle

@@ -24,8 +24,8 @@ android {
         targetSdkVersion rootProject.ext.targetSdkVersion
         multiDexEnabled true
         multiDexKeepProguard file("multidexKeep.pro")//腾讯bugly的类放到主Dex
-        versionCode 343
-        versionName "3.4.3"
+        versionCode 345
+        versionName "3.4.5"
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
         flavorDimensions "versionCode"
         ndk {
@@ -102,6 +102,7 @@ android {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
+
 }
 
 dependencies {

+ 3 - 1
app/src/main/java/com/tongyu/luck/happywork/ui/activity/cclient/clock/ClockUserStatisticsActivity.java

@@ -96,7 +96,9 @@ public class ClockUserStatisticsActivity extends BaseActivity<ClockUserStatistic
     public void onUserData() {
         setLoadingVisible(false);
         setErrorVisible(false);
-        if (!TextUtils.isEmpty(AppCacheManager.getInstance().getLoginModel().getNickName())) {
+        if (AppCacheManager.getInstance().getMemberModel() != null && !TextUtils.isEmpty(AppCacheManager.getInstance().getMemberModel().getRealName())) {
+            tvName.setText(AppCacheManager.getInstance().getMemberModel().getRealName());
+        } else if (!TextUtils.isEmpty(AppCacheManager.getInstance().getLoginModel().getNickName())) {
             tvName.setText(AppCacheManager.getInstance().getLoginModel().getNickName());
         } else {
             tvName.setText("开心用户");

+ 1 - 2
app/src/main/java/com/tongyu/luck/happywork/ui/activity/cclient/mine/RealNameAuthenticationActivity.java

@@ -92,8 +92,7 @@ public class RealNameAuthenticationActivity extends BaseActivity<RealNameAuthent
                 mvpPresenter.getORCData(1);
                 break;
             case R.id.btn_submit:
-                if (mvpPresenter.isValid(tvName.getText().toString(), tvId.getText().toString()))
-                    mvpPresenter.realAuthentication(tvName.getText().toString(), tvId.getText().toString());
+                mvpPresenter.realAuthentication();
                 break;
         }
     }

+ 8 - 3
app/src/main/java/com/tongyu/luck/happywork/ui/fragment/cclient/ClockFragment.java

@@ -231,8 +231,13 @@ public class ClockFragment extends BaseFragment<ClockFragmentPresenter> implemen
                 cvAuthentication.setVisibility(View.GONE);
                 rlTodayMoney.setVisibility(View.GONE);
                 tvRelocation.setVisibility(View.GONE);
-
-                tvName.setText(AppCacheManager.getInstance().getMemberModel() != null && !TextUtils.isEmpty(AppCacheManager.getInstance().getMemberModel().getRealName()) ? AppCacheManager.getInstance().getMemberModel().getRealName() : "开心用户");
+                if (AppCacheManager.getInstance().getMemberModel() != null && !TextUtils.isEmpty(AppCacheManager.getInstance().getMemberModel().getRealName())) {
+                    tvName.setText(AppCacheManager.getInstance().getMemberModel().getRealName());
+                } else if (!TextUtils.isEmpty(AppCacheManager.getInstance().getLoginModel().getNickName())) {
+                    tvName.setText(AppCacheManager.getInstance().getLoginModel().getNickName());
+                } else {
+                    tvName.setText("开心用户");
+                }
                 ImageLoaderUtil.getInstance().loadCircleImage(AppCacheManager.getInstance().getLoginModel().getHeadImgUrl(), R.mipmap.ic_default_header, ivHeader);
 
                 tvWorkHour.setText(infoBean.getSumDuration());
@@ -272,7 +277,7 @@ public class ClockFragment extends BaseFragment<ClockFragmentPresenter> implemen
                         } else {//如果存在上班卡,表示已打上班卡,下班时间未到不可打下班卡
                             vClock.setEnabled(false);
                             vClock.setBackgroundResource(R.mipmap.ic_clock_btn_2_2);
-                            tvClockRangeState.setText("上班" + infoBean.getDailyAvailableMinHour() + "小时才能进行上班打卡");
+                            tvClockRangeState.setText("上班" + infoBean.getDailyAvailableMinHour() + "小时才能进行上班打卡");
                             vClockRangeState.setBackgroundResource(R.mipmap.ic_clock_tips_remind);
                         }
                     } else if (infoBean.getClockType() == AppConstant.CLOCK_TYPE_END) {//下班打卡

+ 3 - 1
app/src/main/java/com/tongyu/luck/happywork/ui/fragment/cclient/MeFragment.java

@@ -220,7 +220,9 @@ public class MeFragment extends BaseFragment<MeFragmentPresenter> implements MeF
      */
     @Override
     public void onUserBean() {
-        if (!TextUtils.isEmpty(AppCacheManager.getInstance().getLoginModel().getNickName())) {
+        if (AppCacheManager.getInstance().getMemberModel() != null && !TextUtils.isEmpty(AppCacheManager.getInstance().getMemberModel().getRealName())) {
+            tvName.setText(AppCacheManager.getInstance().getMemberModel().getRealName());
+        } else if (!TextUtils.isEmpty(AppCacheManager.getInstance().getLoginModel().getNickName())) {
             tvName.setText(AppCacheManager.getInstance().getLoginModel().getNickName());
         } else {
             tvName.setText("开心用户");

+ 5 - 5
app/src/main/java/com/tongyu/luck/happywork/ui/mvp/cclient/contacts/RealNameAuthenticationContacts.java

@@ -27,11 +27,9 @@ public class RealNameAuthenticationContacts {
 
         void onActivityForResult(int requestCode, int resultCode, Intent data);
 
-        void realAuthentication(String name, String idCode);
+        void realAuthentication();
 
         void getOrcKey(boolean isShowDialog);
-
-        boolean isValid(String name, String idCode);
     }
 
     public interface IRealNameAuthenticationModel {
@@ -43,11 +41,13 @@ public class RealNameAuthenticationContacts {
 
         void httpGetOrcKey(boolean isShowDialog, MvpDataCallBack<ApiORCBean> callBack);
 
-        void httpRealAuthentication(String name, String idCode, MvpDataCallBack<Boolean> callBack);
+        void httpRealAuthentication(MvpDataCallBack<Boolean> callBack);
 
         boolean isValidOrc();
 
-        boolean isValid(String name, String idCode);
+        boolean isValid();
+
+        void setResult(IdCardOcrResult result);
 
         void setImagePathPositive(String imagePathPositive);
 

+ 19 - 26
app/src/main/java/com/tongyu/luck/happywork/ui/mvp/cclient/model/RealNameAuthenticationModel.java

@@ -6,6 +6,7 @@ import android.content.Intent;
 import android.text.TextUtils;
 import android.widget.Toast;
 
+import com.tencent.ocr.sdk.entity.IdCardOcrResult;
 import com.tongyu.luck.happywork.AppCacheManager;
 import com.tongyu.luck.happywork.R;
 import com.tongyu.luck.happywork.baselibrary.EventConstant;
@@ -38,6 +39,7 @@ import okhttp3.RequestBody;
 public class RealNameAuthenticationModel extends BaseModel implements RealNameAuthenticationContacts.IRealNameAuthenticationModel {
     private String imagePathPositive, imagePathReverse;
     private ApiORCBean apiORCBean;
+    private IdCardOcrResult result;
     private int clickPosition;
 
     public RealNameAuthenticationModel(Context mContext) {
@@ -131,12 +133,10 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
     /**
      * 实名认证
      *
-     * @param name
-     * @param idCode
      * @param callBack
      */
     @Override
-    public void httpRealAuthentication(String name, String idCode, final MvpDataCallBack<Boolean> callBack) {
+    public void httpRealAuthentication(final MvpDataCallBack<Boolean> callBack) {
         MultipartBody.Builder builder = new RetrofitHttpParams(mContext).getRequestMultipartBody();
         if (FileUtils.isFileExit(imagePathPositive)) {
             File file = new File(imagePathPositive.replace("file://", ""));
@@ -150,8 +150,9 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
                     MediaType.parse("multipart/form-data;charset=UTF-8"), file);
             builder.addFormDataPart("idCardBack", file.getName(), requestBody);
         }
-        builder.addFormDataPart("realName", name);
-        builder.addFormDataPart("idCardNumber", idCode);
+        builder.addFormDataPart("realName", result.getName());
+        builder.addFormDataPart("idCardNumber", result.getIdNum());
+        builder.addFormDataPart("nation", result.getNation());
         new UserSubscribe(mContext).requestRealApprove(builder.build(), new ApiObserver<ApiApproveBean>(mContext, true, false) {
             @Override
             public void onSuccess(ApiApproveBean data) {
@@ -172,6 +173,16 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
     }
 
     /**
+     * 识别结果
+     *
+     * @param result
+     */
+    @Override
+    public void setResult(IdCardOcrResult result) {
+        this.result = result;
+    }
+
+    /**
      * orc是否获得数据
      *
      * @return
@@ -184,34 +195,16 @@ public class RealNameAuthenticationModel extends BaseModel implements RealNameAu
     /**
      * 检查提交数据合法性
      *
-     * @param name
-     * @param idCode
      * @return
      */
     @Override
-    public boolean isValid(String name, String idCode) {
-        if (TextUtils.isEmpty(name)) {
+    public boolean isValid() {
+        if (result == null || !FileUtils.isFileExit(imagePathPositive)) {
             ToastUtils.show(mContext, R.string.toast_input_real_name);
             return false;
         }
-        if (CommonUtils.isHaveSpecialText(name)) {
-            ToastUtils.show(mContext, R.string.toast_input_real_name2);
-            return false;
-        }
-        if (TextUtils.isEmpty(idCode)) {
-            ToastUtils.show(mContext, R.string.toast_input_id_code);
-            return false;
-        }
-        if (!CommonUtils.is18ByteIdCard(idCode)) {
-            ToastUtils.show(mContext, R.string.toast_input_id_code2);
-            return false;
-        }
-        if (!FileUtils.isFileExit(imagePathPositive)) {
-            ToastUtils.show(mContext, R.string.toast_input_choose_image1);
-            return false;
-        }
         if (!FileUtils.isFileExit(imagePathReverse)) {
-            ToastUtils.show(mContext, R.string.toast_input_choose_image2);
+            ToastUtils.show(mContext, R.string.toast_input_receive);
             return false;
         }
         return true;

+ 5 - 34
app/src/main/java/com/tongyu/luck/happywork/ui/mvp/cclient/presenter/RealNameAuthenticationPresenter.java

@@ -87,6 +87,7 @@ public class RealNameAuthenticationPresenter extends BasePresenter<RealNameAuthe
                                     null, IdCardOcrResult.class, new ISdkOcrEntityResultListener<IdCardOcrResult>() {
                                         @Override
                                         public void onProcessSucceed(IdCardOcrResult idCardOcrResult, String base64Str) {
+                                            mRealNameAuthenticationModel.setResult(idCardOcrResult);
                                             String imagePath = BitmapUtils.generateImage(base64Str, FileUtils.getCaChePicturePath());
                                             if (!TextUtils.isEmpty(imagePath)) {
                                                 if (clickPosition == 0) {
@@ -139,14 +140,11 @@ public class RealNameAuthenticationPresenter extends BasePresenter<RealNameAuthe
 
     /**
      * 实名认证
-     *
-     * @param name
-     * @param idCode
      */
     @Override
-    public void realAuthentication(String name, String idCode) {
-        if (isViewAttach() && mRealNameAuthenticationModel.isValid(name, idCode)) {
-            mRealNameAuthenticationModel.httpRealAuthentication(name, idCode, new MvpDataCallBack<Boolean>() {
+    public void realAuthentication() {
+        if (isViewAttach() && mRealNameAuthenticationModel.isValid()) {
+            mRealNameAuthenticationModel.httpRealAuthentication(new MvpDataCallBack<Boolean>() {
                 @Override
                 public void onData(Boolean data) {
                     if (AppCacheManager.getInstance().isLogin()) {
@@ -182,7 +180,7 @@ public class RealNameAuthenticationPresenter extends BasePresenter<RealNameAuthe
                 @Override
                 public void onData(ApiORCBean data) {
                     // 启动参数配置
-                    OcrModeType modeType = OcrModeType.OCR_DETECT_AUTO_MANUAL; // 设置默认的业务识别模式自动 + 手动步骤模式
+                    OcrModeType modeType = OcrModeType.OCR_DETECT_MANUAL; // 设置默认的业务识别模式自动 + 手动步骤模式
                     OcrType ocrType = OcrType.IDCardOCR_FRONT; // 设置默认的业务识别,银行卡
                     OcrSDKConfig configBuilder = OcrSDKConfig.newBuilder(data.getSecretId(), data.getSecretKey(), null)
                             .ocrType(ocrType)
@@ -201,31 +199,4 @@ public class RealNameAuthenticationPresenter extends BasePresenter<RealNameAuthe
         }
     }
 
-    /**
-     * 判断数据合法性
-     *
-     * @param name
-     * @param idCode
-     * @return
-     */
-    @Override
-    public boolean isValid(String name, String idCode) {
-        if (TextUtils.isEmpty(name)) {
-            ToastUtils.show(mvpReference.get(), R.string.toast_input_real_name);
-            return false;
-        }
-        if (CommonUtils.isHaveSpecialText(name)) {
-            ToastUtils.show(mvpReference.get(), R.string.toast_input_real_name2);
-            return false;
-        }
-        if (TextUtils.isEmpty(idCode)) {
-            ToastUtils.show(mvpReference.get(), R.string.toast_input_id_code);
-            return false;
-        }
-        if (!CommonUtils.is18ByteIdCard(idCode)) {
-            ToastUtils.show(mvpReference.get(), R.string.toast_input_id_code2);
-            return false;
-        }
-        return true;
-    }
 }

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -797,6 +797,8 @@
     <string name="toast_input_real_name2">姓名有误,请重新识别身份证正面</string>
     <string name="toast_input_id_code">请识别身份证正面</string>
     <string name="toast_input_id_code2">身份证号有误,请重新识别身份证正面</string>
+    <string name="toast_input_nation">请识别身份证正面</string>
+    <string name="toast_input_receive">请识别身份证背面</string>
     <string name="toast_input_choose_image1">请选择身份证正面照</string>
     <string name="toast_input_choose_image2">请选择身份证背面照</string>
     <string name="toast_input_choose_image3">请选择手持身份证照</string>

BIN
baselibrary/libs/pinyin4j-2.5.0.jar


+ 20 - 20
baselibrary/src/main/java/com/tongyu/luck/happywork/baselibrary/utils/PinYinUtils.java

@@ -1,25 +1,25 @@
 package com.tongyu.luck.happywork.baselibrary.utils;
 
-import net.sourceforge.pinyin4j.PinyinHelper;
+//import net.sourceforge.pinyin4j.PinyinHelper;
 
 public class PinYinUtils {
-    /**
-     * 得到中文首字母
-     *
-     * @param str 需要转化的中文字符串
-     * @return
-     */
-    public static String getPinYinHeadChar(String str) {
-        String convert = "";
-        for (int j = 0; j < str.length(); j++) {
-            char word = str.charAt(j);
-            String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
-            if (pinyinArray != null) {
-                convert += pinyinArray[0].charAt(0);
-            } else {
-                convert += word;
-            }
-        }
-        return convert.toUpperCase().substring(0, 1);
-    }
+//    /**
+//     * 得到中文首字母
+//     *
+//     * @param str 需要转化的中文字符串
+//     * @return
+//     */
+//    public static String getPinYinHeadChar(String str) {
+//        String convert = "";
+//        for (int j = 0; j < str.length(); j++) {
+//            char word = str.charAt(j);
+//            String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word);
+//            if (pinyinArray != null) {
+//                convert += pinyinArray[0].charAt(0);
+//            } else {
+//                convert += word;
+//            }
+//        }
+//        return convert.toUpperCase().substring(0, 1);
+//    }
 }

+ 3 - 1
build.gradle

@@ -4,6 +4,7 @@ buildscript {
 
     repositories {
         google()
+        mavenCentral()
         jcenter()
     }
     dependencies {
@@ -16,9 +17,10 @@ buildscript {
 
 allprojects {
     repositories {
+        maven { url "https://jitpack.io" }
         google()
+        mavenCentral()
         jcenter()
-        maven { url 'https://jitpack.io' }
         flatDir {
             dirs 'libs', '../baselibrary/libs'
         }