Commit 939d0202ac25521ddcd359d77fecb3b02172a976
1 parent
b42c3ab0
畅游通标准4.0:新增动态二维码解析
Showing
6 changed files
with
108 additions
and
12 deletions
build.gradle
| ... | ... | @@ -7,9 +7,9 @@ buildscript { |
| 7 | 7 | mavenCentral() |
| 8 | 8 | jcenter() |
| 9 | 9 | google() |
| 10 | - maven { url "https://jitpack.io"} | |
| 11 | - maven { url "https://maven.aliyun.com/repository/google"} | |
| 12 | - maven { url "https://maven.aliyun.com/repository/public"} | |
| 10 | + maven { url "https://jitpack.io" } | |
| 11 | + maven { url "https://maven.aliyun.com/repository/google" } | |
| 12 | + maven { url "https://maven.aliyun.com/repository/public" } | |
| 13 | 13 | // maven { url "https://maven.aliyun.com/repository/releases"} |
| 14 | 14 | // maven { url "https://maven.aliyun.com/repository/central"} |
| 15 | 15 | // maven { url "https://maven.aliyun.com/repository/gradle-plugin"} |
| ... | ... | @@ -52,6 +52,7 @@ dependencies { |
| 52 | 52 | implementation files('libs\\jsch-0.1.54.jar') |
| 53 | 53 | implementation 'org.jetbrains:annotations-java5:15.0' |
| 54 | 54 | implementation files('libs\\zxingcore-2.3.0.jar') |
| 55 | + implementation files('libs\\cyt-common-dynamic-code-3.6.4.jar') | |
| 55 | 56 | compileOnly files('external_libs/classes_2.1.11_20160907.jar') |
| 56 | 57 | compileOnly files('external_libs/bw_odm_20160526.jar') |
| 57 | 58 | implementation files('libs/bw_pos_sdk2.0.18.jar') |
| ... | ... | @@ -95,6 +96,11 @@ android { |
| 95 | 96 | } |
| 96 | 97 | } |
| 97 | 98 | |
| 99 | + compileOptions { | |
| 100 | + sourceCompatibility JavaVersion.VERSION_1_8 | |
| 101 | + targetCompatibility JavaVersion.VERSION_1_8 | |
| 102 | + } | |
| 103 | + | |
| 98 | 104 | //在apk文件后边生成版本号信息 |
| 99 | 105 | android.applicationVariants.all { |
| 100 | 106 | variant -> |
| ... | ... | @@ -131,7 +137,7 @@ android { |
| 131 | 137 | defaultConfig { |
| 132 | 138 | minSdkVersion 19 |
| 133 | 139 | targetSdkVersion 30 |
| 134 | - vectorDrawables.useSupportLibrary =true | |
| 140 | + vectorDrawables.useSupportLibrary = true | |
| 135 | 141 | |
| 136 | 142 | ndk { |
| 137 | 143 | abiFilters "armeabi", "armeabi-v7a"//可以适当补填其他 |
| ... | ... | @@ -165,7 +171,7 @@ repositories { |
| 165 | 171 | mavenCentral() |
| 166 | 172 | jcenter() |
| 167 | 173 | google() |
| 168 | - maven { url "https://jitpack.io"} | |
| 169 | - maven { url "https://maven.aliyun.com/repository/google"} | |
| 170 | - maven { url "https://maven.aliyun.com/repository/public"} | |
| 174 | + maven { url "https://jitpack.io" } | |
| 175 | + maven { url "https://maven.aliyun.com/repository/google" } | |
| 176 | + maven { url "https://maven.aliyun.com/repository/public" } | |
| 171 | 177 | } |
| 172 | 178 | \ No newline at end of file | ... | ... |
libs/cyt-common-dynamic-code-3.6.4.jar
0 → 100644
No preview for this file type
src/com/ectrip/cyt/ui/NewHandleScanerActivity.java
| ... | ... | @@ -8,6 +8,7 @@ import java.io.OutputStream; |
| 8 | 8 | import java.io.UnsupportedEncodingException; |
| 9 | 9 | import java.security.InvalidParameterException; |
| 10 | 10 | import java.util.ArrayList; |
| 11 | +import java.util.Date; | |
| 11 | 12 | import java.util.concurrent.atomic.AtomicBoolean; |
| 12 | 13 | |
| 13 | 14 | import android.app.AlertDialog; |
| ... | ... | @@ -23,6 +24,9 @@ import android.widget.Toast; |
| 23 | 24 | |
| 24 | 25 | import android_serialport_api.SerialPortNewHandset; |
| 25 | 26 | |
| 27 | +import com.ectrip.common.dynamic.code.core.DynamicVerifyCodeTool; | |
| 28 | +import com.ectrip.common.dynamic.code.exception.DynamicVerifyCodeException; | |
| 29 | +import com.ectrip.common.dynamic.code.model.DynamicVerifyCodeDecodeResult; | |
| 26 | 30 | import com.ectrip.cyt.bean.ConfigBean; |
| 27 | 31 | import com.ectrip.cyt.config.DevicTool; |
| 28 | 32 | import com.ectrip.cyt.config.MyApp; |
| ... | ... | @@ -159,7 +163,7 @@ public class NewHandleScanerActivity extends BaseActivity { |
| 159 | 163 | } else { |
| 160 | 164 | try { |
| 161 | 165 | if (result.startsWith("CYT_")) { |
| 162 | - LogUtil.i(TAG,"result = " + result); | |
| 166 | + LogUtil.i(TAG, "result = " + result); | |
| 163 | 167 | typeScan = 0; |
| 164 | 168 | if (result.contains(",")) { |
| 165 | 169 | result = result.substring(result.indexOf("_") + 1, result.indexOf(",")); |
| ... | ... | @@ -186,6 +190,31 @@ public class NewHandleScanerActivity extends BaseActivity { |
| 186 | 190 | } else if ((result.startsWith("TY_") || (result.startsWith("PMS_")))) { |
| 187 | 191 | typeScan = 1; |
| 188 | 192 | result = result; |
| 193 | + } else if (result.startsWith("OCP_")) { | |
| 194 | + typeScan = 0; | |
| 195 | + result = result; | |
| 196 | + } else if (result.startsWith("DYV_")) { | |
| 197 | + try { | |
| 198 | + DynamicVerifyCodeDecodeResult decodeResult = DynamicVerifyCodeTool.decodeDynamicCode(result); | |
| 199 | + boolean expired = decodeResult.getExpired(); | |
| 200 | + String staticCode = decodeResult.getStaticCode(); | |
| 201 | + Date expireTime = decodeResult.getExpireTime(); | |
| 202 | + LogUtil.d(TAG, "expired = " + expired); | |
| 203 | + LogUtil.d(TAG, "staticCode = " + staticCode); | |
| 204 | + LogUtil.d(TAG, "expireTime = " + expireTime); | |
| 205 | + if (!expired) { | |
| 206 | + typeScan = 1; | |
| 207 | + result = staticCode; | |
| 208 | + } else { | |
| 209 | + typeScan = 2; | |
| 210 | + result = "动态二维码已过有效期"; | |
| 211 | + } | |
| 212 | + } catch (DynamicVerifyCodeException e) { | |
| 213 | + typeScan = 2; | |
| 214 | + LogUtil.d(TAG, "动态核销码异常:" + e.getMessage()); | |
| 215 | + result = e.getMessage(); | |
| 216 | + e.printStackTrace(); | |
| 217 | + } | |
| 189 | 218 | } else { |
| 190 | 219 | typeScan = 1; |
| 191 | 220 | result = result; | ... | ... |
src/com/ectrip/cyt/ui/PhomeScanerOrderActivity.java
| ... | ... | @@ -2,6 +2,7 @@ package com.ectrip.cyt.ui; |
| 2 | 2 | |
| 3 | 3 | import java.io.IOException; |
| 4 | 4 | import java.util.ArrayList; |
| 5 | +import java.util.Date; | |
| 5 | 6 | import java.util.Vector; |
| 6 | 7 | |
| 7 | 8 | import android.content.Intent; |
| ... | ... | @@ -22,6 +23,9 @@ import android.view.WindowManager; |
| 22 | 23 | import android.widget.TextView; |
| 23 | 24 | import android.widget.Toast; |
| 24 | 25 | |
| 26 | +import com.ectrip.common.dynamic.code.core.DynamicVerifyCodeTool; | |
| 27 | +import com.ectrip.common.dynamic.code.exception.DynamicVerifyCodeException; | |
| 28 | +import com.ectrip.common.dynamic.code.model.DynamicVerifyCodeDecodeResult; | |
| 25 | 29 | import com.ectrip.cyt.bean.ConfigBean; |
| 26 | 30 | import com.ectrip.cyt.config.DevicTool; |
| 27 | 31 | import com.ectrip.cyt.constant.constant; |
| ... | ... | @@ -174,6 +178,28 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback { |
| 174 | 178 | } else if (resultString.startsWith("OCP_")) { |
| 175 | 179 | typeScan = 0; |
| 176 | 180 | resultString = resultString; |
| 181 | + } else if (resultString.startsWith("DYV_")) { | |
| 182 | + try { | |
| 183 | + DynamicVerifyCodeDecodeResult decodeResult = DynamicVerifyCodeTool.decodeDynamicCode(resultString); | |
| 184 | + boolean expired = decodeResult.getExpired(); | |
| 185 | + String staticCode = decodeResult.getStaticCode(); | |
| 186 | + Date expireTime = decodeResult.getExpireTime(); | |
| 187 | + LogUtil.d(TAG, "expired = " + expired); | |
| 188 | + LogUtil.d(TAG, "staticCode = " + staticCode); | |
| 189 | + LogUtil.d(TAG, "expireTime = " + expireTime); | |
| 190 | + if (!expired) { | |
| 191 | + typeScan = 1; | |
| 192 | + resultString = staticCode; | |
| 193 | + } else { | |
| 194 | + typeScan = 2; | |
| 195 | + resultString = "动态二维码已过有效期"; | |
| 196 | + } | |
| 197 | + } catch (DynamicVerifyCodeException e) { | |
| 198 | + typeScan = 2; | |
| 199 | + LogUtil.d(TAG, "动态核销码异常:" + e.getMessage()); | |
| 200 | + resultString = e.getMessage(); | |
| 201 | + e.printStackTrace(); | |
| 202 | + } | |
| 177 | 203 | } else { |
| 178 | 204 | typeScan = 1; |
| 179 | 205 | resultString = resultString; |
| ... | ... | @@ -186,8 +212,8 @@ public class PhomeScanerOrderActivity extends BaseActivity implements Callback { |
| 186 | 212 | // intent = new Intent(PhomeScanerOrderActivity.this, |
| 187 | 213 | // PhoneCodeListActivity.class); |
| 188 | 214 | // } else { |
| 189 | - intent = new Intent(PhomeScanerOrderActivity.this, | |
| 190 | - QRCodeOrderListActivity.class); | |
| 215 | + intent = new Intent(PhomeScanerOrderActivity.this, | |
| 216 | + QRCodeOrderListActivity.class); | |
| 191 | 217 | // } |
| 192 | 218 | intent.putExtra("mode", 1); |
| 193 | 219 | intent.putExtra("input_orid", resultString); | ... | ... |
src/com/ectrip/cyt/ui/QRCodeOrderListActivity.java
| ... | ... | @@ -103,6 +103,12 @@ public class QRCodeOrderListActivity extends BaseActivity implements ListOnclick |
| 103 | 103 | LogUtil.d(TAG, "orid = " + orid); |
| 104 | 104 | typeScan = getIntent().getIntExtra("typeScan", 0); |
| 105 | 105 | LogUtil.d(TAG, "typeScan = " + typeScan); |
| 106 | + if (typeScan == 2) { | |
| 107 | + orderList.setEmptyView(errorLayout); | |
| 108 | + errorLayout.setVisibility(View.VISIBLE); | |
| 109 | + errorInfo.setText(orid); | |
| 110 | + return; | |
| 111 | + } | |
| 106 | 112 | if (orid.startsWith("OCP_")) { |
| 107 | 113 | ArrayList<ProductOfConsumeOrder> productOfConsumeOrders = new ArrayList<>(); |
| 108 | 114 | ProductOfConsumeOrder productOfConsumeOrder = new ProductOfConsumeOrder(); | ... | ... |
src/com/ectrip/cyt/ui/ScanerOrderActivity.java
| ... | ... | @@ -23,6 +23,9 @@ import android.view.View.OnClickListener; |
| 23 | 23 | import android.widget.FrameLayout; |
| 24 | 24 | import android.widget.TextView; |
| 25 | 25 | |
| 26 | +import com.ectrip.common.dynamic.code.core.DynamicVerifyCodeTool; | |
| 27 | +import com.ectrip.common.dynamic.code.exception.DynamicVerifyCodeException; | |
| 28 | +import com.ectrip.common.dynamic.code.model.DynamicVerifyCodeDecodeResult; | |
| 26 | 29 | import com.ectrip.cyt.bean.ConfigBean; |
| 27 | 30 | import com.ectrip.cyt.constant.constant; |
| 28 | 31 | import com.ectrip.cyt.db.DbManager; |
| ... | ... | @@ -45,6 +48,7 @@ import net.sourceforge.zbar.SymbolSet; |
| 45 | 48 | |
| 46 | 49 | import java.io.IOException; |
| 47 | 50 | import java.util.ArrayList; |
| 51 | +import java.util.Date; | |
| 48 | 52 | |
| 49 | 53 | /** |
| 50 | 54 | * 二维码pos版扫描 |
| ... | ... | @@ -240,6 +244,31 @@ public class ScanerOrderActivity extends BaseActivity { |
| 240 | 244 | } else if ((scannerResult.startsWith("TY_") || (scannerResult.startsWith("PMS_")))) { |
| 241 | 245 | typeScan = 1; |
| 242 | 246 | scannerResult = scannerResult; |
| 247 | + } else if (scannerResult.startsWith("OCP_")) { | |
| 248 | + typeScan = 0; | |
| 249 | + result = result; | |
| 250 | + } else if (scannerResult.startsWith("DYV_")) { | |
| 251 | + try { | |
| 252 | + DynamicVerifyCodeDecodeResult decodeResult = DynamicVerifyCodeTool.decodeDynamicCode(scannerResult); | |
| 253 | + boolean expired = decodeResult.getExpired(); | |
| 254 | + String staticCode = decodeResult.getStaticCode(); | |
| 255 | + Date expireTime = decodeResult.getExpireTime(); | |
| 256 | + LogUtil.d(TAG, "expired = " + expired); | |
| 257 | + LogUtil.d(TAG, "staticCode = " + staticCode); | |
| 258 | + LogUtil.d(TAG, "expireTime = " + expireTime); | |
| 259 | + if (!expired) { | |
| 260 | + typeScan = 1; | |
| 261 | + scannerResult = staticCode; | |
| 262 | + } else { | |
| 263 | + typeScan = 2; | |
| 264 | + scannerResult = "动态二维码已过有效期"; | |
| 265 | + } | |
| 266 | + } catch (DynamicVerifyCodeException e) { | |
| 267 | + typeScan = 2; | |
| 268 | + LogUtil.d(TAG, "动态核销码异常:" + e.getMessage()); | |
| 269 | + scannerResult = e.getMessage(); | |
| 270 | + e.printStackTrace(); | |
| 271 | + } | |
| 243 | 272 | } else { |
| 244 | 273 | typeScan = 1; |
| 245 | 274 | scannerResult = scannerResult; |
| ... | ... | @@ -263,8 +292,8 @@ public class ScanerOrderActivity extends BaseActivity { |
| 263 | 292 | } |
| 264 | 293 | } |
| 265 | 294 | |
| 266 | - }else{ | |
| 267 | - LogUtil.d(TAG,"未扫到数据"); | |
| 295 | + } else { | |
| 296 | + LogUtil.d(TAG, "未扫到数据"); | |
| 268 | 297 | } |
| 269 | 298 | } |
| 270 | 299 | }; | ... | ... |