| | |
| | | applicationId "com.dayu.recharge" |
| | | minSdk 23 |
| | | targetSdk 26 |
| | | versionCode 260 |
| | | versionName "2.6.0" |
| | | versionCode 261 |
| | | versionName "2.6.1" |
| | | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" |
| | | |
| | | ndk { |
| | |
| | | userCard.setUserCodeNumber(Integer.valueOf(userCode.substring(12, 16))); |
| | | userCardBean.setCardNumber(cardNumber); |
| | | userCardBean.setUserCode(userCode); |
| | | baseDao.userCardDao().insert(userCardBean); |
| | | if (WriteCardUtils.setUser(intent, userCard, NFCWreatActivity.this)) { |
| | | confromOpenCard(t.getData().getIccardRechargeRecordId(), 0); |
| | | } else { |
| | |
| | | public void onNext(BaseResponse<LoginResult> t) { |
| | | if (t.isSuccess()) { |
| | | //{"code":"0","msg":"操作成功","data":{"chargeMethod":"","iccardCancelTime":"","lastRechargeTime":"2024-08-05 17:04:15","thisSaleMoney":"","totalRechargeWaterAmount":0.00,"iccardBalanceAmonunt":0.00,"iccardInfoId":"1820385315354320898","iccardProtocolName":"","totalRechargeElectricAmount":0.00,"logicState":1,"username":"","state":1,"familySize":"","yearRechargeMoney":0.00,"thisSaleAmount":"","onlyRechargeMoney":"","identityCard":"","iccardBrand":"","iccardBalanceMoney":0.00,"openOperatorUsername":"","adName":"","rechargeWaterAmount":"","openOperatorUserId":"1816297106145103873","lastSwipeTime":"","address":"","yearCompensateMoney":0.00,"iccardProtocolOpenMoney":"","peasantId":"1820374742679953410","reissueTimes":0,"iccardProtocolReissueMoney":"","iccardProtocolId":"","yearRechargeWaterAmount":0.00,"iccardBalanceElectric":0.00,"iccardStatus":0,"phone":"","lastRechargeMoney":0.00,"iccardOpenTime":"","yearRechargeElectricAmount":0.00,"reissueRechargeRecordId":"","iccardPrice":1.50,"iccardNum":"3714251023011","accountType":0,"equipCode":"","rechargeWaterMoney":"","totalRechargeMoney":0.00,"executeWaterPrice":"","iccardType":1,"iccardCode":"BADA4044"}} |
| | | startDetailActivity("终端写卡"); |
| | | if (writeCardStatus == 0) { |
| | | baseDao.userCardDao().insert(userCardBean); |
| | | startDetailActivity("终端写卡"); |
| | | } else { |
| | | TipUtil.show(NFCWreatActivity.this, "写卡失败请重新贴卡!"); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | |
| | | @Override |
| | | public void onNext(BaseResponse<LoginResult> t) { |
| | | if (t.isSuccess()) { |
| | | |
| | | try { |
| | | baseDao.rechargeDao().insert(rechargeBean); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | if (writeCardStatus == 0) { |
| | | try { |
| | | baseDao.rechargeDao().insert(rechargeBean); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 打印相关 |
| | | PrintUtils.printerData(rechargeBean); |
| | | startDetailActivity("终端写卡"); |
| | | } else { |
| | | TipUtil.show(NFCWreatActivity.this, "写卡失败请重新贴卡!"); |
| | | } |
| | | // 打印相关 |
| | | PrintUtils.printerData(rechargeBean); |
| | | startDetailActivity("终端写卡"); |
| | | } else { |
| | | ToastUtil.show(t.getMsg()); |
| | | } |
| | |
| | | |
| | | import com.dayu.baselibrary.tools.BcdUtil; |
| | | import com.dayu.baselibrary.tools.HexUtil; |
| | | |
| | | import com.dayu.qiheonlinelibrary.utils.CardCommon; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Arrays; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | |
| | |
| | | |
| | | public Float electricPrice;//电单价,保留三位小数 |
| | | |
| | | /** |
| | | * 写卡完成后校验是否写卡成功 |
| | | * |
| | | * @param data |
| | | * @return |
| | | */ |
| | | public boolean equlsUserCard(List<byte[]> data) { |
| | | // 参数验证 |
| | | if (data == null || data.size() < 3) { |
| | | return false; |
| | | } |
| | | // 定义要比较的字节数组 |
| | | byte[][] expectedBytes = {getZeroBytes(), getOneBytes(), getTwoBytes()}; |
| | | // 逐个比较字节数组 |
| | | for (int i = 0; i < 3; i++) { |
| | | if (!Arrays.equals(data.get(i), expectedBytes[i])) { |
| | | return false; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 返回完整的用户编号 |
| | |
| | | public void setElectricPrice(Float electricPrice) { |
| | | this.electricPrice = electricPrice; |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | import com.dayu.qiheonlinelibrary.card.UserCard; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author zx |
| | |
| | | int a = 1; |
| | | try { |
| | | MifareClassic mfc = MifareClassic.get(tag); |
| | | List<byte[]> list = new ArrayList<>(); |
| | | if (null != mfc) { |
| | | try { |
| | | //连接NFC |
| | |
| | | //写卡 |
| | | mfc.writeBlock(bIndex + b, data); |
| | | } |
| | | return true; |
| | | int bIndex = mfc.sectorToBlock(1); |
| | | for (int j = 0; j < 3; j++) { |
| | | //读取数据 |
| | | byte[] data = null; |
| | | try { |
| | | data = mfc.readBlock(bIndex); |
| | | bIndex++; |
| | | list.add(data); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if (userCard.equlsUserCard(list)) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | return false; |
| | | } catch (Exception e) { |
| | |
| | | boolean isOpen = mfc.authenticateSectorWithKeyA(sector, defauleKey); |
| | | if (!isOpen) { |
| | | isOpen = mfc.authenticateSectorWithKeyA(sector, companyKey2); |
| | | if (isOpen){ |
| | | if (isOpen) { |
| | | mfc.authenticateSectorWithKeyB(sector, companyKey2); |
| | | } |
| | | } |
| | | if (!isOpen) { |
| | | isOpen = mfc.authenticateSectorWithKeyA(sector, companyKey); |
| | | if (isOpen){ |
| | | if (isOpen) { |
| | | mfc.authenticateSectorWithKeyB(sector, companyKey); |
| | | } |
| | | } |
| | |
| | | //获取写的扇区的块的数量 |
| | | int blockCount = mfc.getBlockCountInSector(sector); |
| | | int blockIndex = mfc.sectorToBlock(sector); |
| | | for (int block = 0; block < blockCount ; block++) { |
| | | for (int block = 0; block < blockCount; block++) { |
| | | // 跳过第 0 扇区的第 0 块 |
| | | if (sector == 0 && block == 0) { |
| | | blockIndex++; |
| | |
| | | mfc.writeBlock(blockIndex, initDataBytes); |
| | | } |
| | | //写卡 |
| | | |
| | | blockIndex++; |
| | | } |
| | | } |
| | |
| | | android:layout_width="0dp" |
| | | android:layout_height="wrap_content" |
| | | android:layout_weight="1" |
| | | android:text="" |
| | | android:text="测试23" |
| | | android:textSize="@dimen/new_card_size" /> |
| | | |
| | | <ImageView |
| | |
| | | android:digits="0123456789Xx" |
| | | android:inputType="text" |
| | | android:maxLength="18" |
| | | android:text="" |
| | | android:text="130107199210160011" |
| | | android:textSize="@dimen/new_card_size" /> |
| | | |
| | | |
| | |
| | | android:layout_height="wrap_content" |
| | | android:inputType="number" |
| | | android:maxLength="11" |
| | | android:text="" |
| | | android:text="15802220723" |
| | | android:textSize="@dimen/new_card_size" /> |
| | | </LinearLayout> |
| | | |