| | |
| | | import com.dayu.baselibrary.utils.DeviceUtils; |
| | | import com.dayu.baselibrary.utils.MornyUtil; |
| | | import com.dayu.baselibrary.utils.TipUtil; |
| | | import com.dayu.baselibrary.utils.ToastUtil; |
| | | import com.dayu.baselibrary.view.ConfirmDialog; |
| | | import com.dayu.baselibrary.view.TitleBar; |
| | | import com.dayu.qiheonlinelibrary.QHOnLineApplication; |
| | |
| | | import com.dayu.qiheonlinelibrary.card.DomainCard; |
| | | import com.dayu.qiheonlinelibrary.card.ElectricPriceCard; |
| | | import com.dayu.qiheonlinelibrary.card.ManageCard; |
| | | import com.dayu.qiheonlinelibrary.card.ManagerToUserCard; |
| | | import com.dayu.qiheonlinelibrary.card.PassWordCard; |
| | | import com.dayu.qiheonlinelibrary.card.RegionCard; |
| | | import com.dayu.qiheonlinelibrary.card.RegisteredCard; |
| | |
| | | import com.dayu.qiheonlinelibrary.tools.WriteCardUtils; |
| | | import com.dayu.qiheonlinelibrary.utils.CardCommon; |
| | | import com.dayu.qiheonlinelibrary.utils.NFCWreatUtils; |
| | | import com.dayu.qiheonlinelibrary.utils.PrintUtils; |
| | | import com.dayu.qiheonlinelibrary.view.ReplacementPriceDialog; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | |
| | | //补卡工本费用 |
| | | String rechargeCardMoney; |
| | | ReplacementPriceDialog replacementPriceDialog; |
| | | ManagerToUserCard managerToUserCard; |
| | | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | |
| | | userCardBean = (UserCardBean) this.getIntent().getSerializableExtra("dbUserCard"); |
| | | isUser = true; |
| | | } |
| | | if (this.getIntent().hasExtra("userCardBean")) { |
| | | userCardBean = (UserCardBean) this.getIntent().getSerializableExtra("userCardBean"); |
| | | } |
| | | if (this.getIntent().hasExtra("cleanUserCard")) { |
| | | cleanUserCard = (CleanUserCard) this.getIntent().getSerializableExtra("cleanUserCard"); |
| | | binding.cardData.setText("制作删除全部用户卡"); |
| | |
| | | morny = this.getIntent().getStringExtra("morny"); |
| | | userName = this.getIntent().getStringExtra("userName"); |
| | | rechargeBean = (RechargeBean) this.getIntent().getSerializableExtra("rechargeBean"); |
| | | |
| | | // rechageWater = this.getIntent().getStringExtra("rechageWater"); |
| | | binding.cardData.setText("充值金额:" + morny + " 元"); |
| | | if (MornyUtil.changeY2F(rechargeBean.getDeductionMorny()) == 0) { |
| | | binding.cardData.setText("充值金额:" + morny + " 元"); |
| | | } else { |
| | | int realityMorny = MornyUtil.changeY2F(morny) - MornyUtil.changeY2F(rechargeBean.getDeductionMorny()); |
| | | binding.cardData.setText("充值金额:" + morny + " 元\n" + "补扣金额:" + rechargeBean.getDeductionMorny() + " 元\n实际到账金额:" + MornyUtil.changeF2Y(realityMorny) + " 元"); |
| | | } |
| | | } |
| | | if (this.getIntent().hasExtra("iccardInfoId")) { |
| | | iccardInfoId = this.getIntent().getStringExtra("iccardInfoId"); |
| | | //补卡类型 |
| | | replaceType = this.getIntent().getIntExtra("replaceType", 0); |
| | | replacementPriceDialog = new ReplacementPriceDialog(this, data -> { |
| | | if (TextUtils.isEmpty(data)) { |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 打印机相关信息 |
| | | * |
| | | * @param rechargeBean |
| | | */ |
| | | private void setPrinterData(RechargeBean rechargeBean) { |
| | | try { |
| | | StringBuffer data = new StringBuffer(); |
| | | if (rechargeBean != null) { |
| | | data.append("*****************************" + "\n"); |
| | | data.append("设备序列号:" + rechargeBean.getSerial() + "\n"); |
| | | data.append("用户名:" + rechargeBean.getUserName() + "\n"); |
| | | data.append("卡 号:" + rechargeBean.getCardNumber() + "\n"); |
| | | data.append("充值金额:" + rechargeBean.getMorny() + " 元" + "\n"); |
| | | data.append("卡内余额:" + rechargeBean.getBalance() + " 元" + "\n"); |
| | | data.append("日 期:" + DateUtil.dateToStamp(rechargeBean.getRechargeDate(), DateUtil.type2) + "\n\n"); |
| | | data.append("*****************************"); |
| | | } |
| | | float size = 26; |
| | | |
| | | try { |
| | | AidlUtil.getInstance().printText(data.toString(), size, true, false); |
| | | AidlUtil.getInstance().print3Line(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | | } |
| | | } |
| | | |
| | | void startAnim() { |
| | | binding.avi.show(); |
| | | // or avi.smoothToShow(); |
| | |
| | | } |
| | | } |
| | | |
| | | private void startDetailActivity(String userName, String statu) { |
| | | private void startDetailActivity(String statu) { |
| | | Intent detail = new Intent(this, RechargeDetailActivity.class); |
| | | detail.putExtra("userName", userName); |
| | | detail.putExtra("statu", statu); |
| | | detail.putExtra("userCard", userCard); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | detail.putExtra("morny", morny); |
| | | detail.putExtra("rechargeBean", rechargeBean); |
| | | } |
| | | if (!TextUtils.isEmpty(cardNumber)) { |
| | | detail.putExtra("cardNumber", cardNumber); |
| | | } |
| | | |
| | | detail.putExtra("rechargeBean", rechargeBean); |
| | | } else { |
| | | detail.putExtra("userCardBean", userCardBean); |
| | | } |
| | | startActivity(detail); |
| | | if (NewCardActivity.newCardActivity != null) { |
| | | NewCardActivity.newCardActivity.finish(); |
| | |
| | | data.put("iccardNum", iccardNum);//物理卡号 |
| | | data.put("iccardType", iccardType); |
| | | data.put("peasantId", peasantId); |
| | | data.put("adcd", QHOnLineApplication.getInstance().adcd); |
| | | //工本费 |
| | | data.put("rechargeCardMoney", rechargeMoney); |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/iccard/recharge/openCard", OpenCardResult.class, data, new SubscriberListener<BaseResponse<OpenCardResult>>() { |
| | | ApiManager.getInstance().requestPostLoading(this, "iccard/recharge/openCard", OpenCardResult.class, data, new SubscriberListener<BaseResponse<OpenCardResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<OpenCardResult> t) { |
| | | if (t.isSuccess()) { |
| | |
| | | data.put("writeCardStatus", writeCardStatus); |
| | | |
| | | |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/iccard/recharge/openCardResult", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() { |
| | | ApiManager.getInstance().requestPostLoading(this, "iccard/recharge/openCardResult", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() { |
| | | @Override |
| | | 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(userCardBean.getUserName(), "终端写卡"); |
| | | startDetailActivity("终端写卡"); |
| | | } |
| | | } |
| | | }); |
| | |
| | | data.put("writeCardStatus", writeCardStatus); |
| | | data.put("writeCardStatus", writeCardStatus); |
| | | |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/iccard/recharge/rechargeCardResult", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() { |
| | | ApiManager.getInstance().requestPostLoading(this, "iccard/recharge/rechargeCardResult", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<LoginResult> t) { |
| | | if (t.isSuccess()) { |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | // 打印相关 |
| | | setPrinterData(rechargeBean); |
| | | startDetailActivity(rechargeBean.getUserName(), "终端写卡"); |
| | | PrintUtils.printerData(rechargeBean); |
| | | startDetailActivity("终端写卡"); |
| | | } else { |
| | | ToastUtil.show(t.getMsg()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 补卡逻辑 |
| | | */ |
| | | private void replaceCard() { |
| | | cardNumber = NfcReadHelper.getInstence(intent, this).getCardNumber(); |
| | | if (replaceType == BaseCommon.REPLACE_NO_CARD) { |
| | | replaceCardPost("", ""); |
| | | } else if (replaceType == BaseCommon.REPLACE_HAS_CARD) { |
| | | managerToUserCard = NfcReadHelper.getInstence(intent, NFCWreatActivity.this).getManagerToUserCardData(); |
| | | //判断是否已经在控制器端刷卡 |
| | | if (managerToUserCard.getCardWriteState() == 1) { |
| | | replaceCardPost(MornyUtil.changeF2Y(managerToUserCard.getBalance()), MornyUtil.changeF2Y(managerToUserCard.getSurplusElecticity())); |
| | | } else { |
| | | TipUtil.show("请在控制器端刷卡"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 补卡 |
| | |
| | | data.put("iccardInfoId", iccardInfoId); |
| | | //新卡的物理卡号 |
| | | data.put("iccardNum", cardNumber); |
| | | //卡内剩余金额 |
| | | data.put("iccardBalanceMoney", iccardBalanceMoney); |
| | | //卡内剩余电量 |
| | | data.put("iccardBalanceElectric", iccardBalanceElectric); |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/iccard/recharge/reissueOpenCard", ReplaceCardResult.class, data, new SubscriberListener<BaseResponse<ReplaceCardResult>>() { |
| | | if (!TextUtils.isEmpty(iccardBalanceMoney)) { |
| | | //卡内剩余金额 |
| | | data.put("iccardBalanceMoney", iccardBalanceMoney); |
| | | } |
| | | if (!TextUtils.isEmpty(iccardBalanceElectric)) { |
| | | //卡内剩余电量 |
| | | data.put("iccardBalanceElectric", iccardBalanceElectric); |
| | | } |
| | | ApiManager.getInstance().requestPostLoading(this, "iccard/recharge/reissueOpenCard", ReplaceCardResult.class, data, new SubscriberListener<BaseResponse<ReplaceCardResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<ReplaceCardResult> t) { |
| | | if (t.isSuccess()) { |
| | |
| | | userCard.setRechargeDate(Calendar.getInstance()); |
| | | userCard.setElectricPrice(Float.valueOf(QHOnLineApplication.getInstance().electriclePriceStr)); |
| | | if (WriteCardUtils.setUser(intent, userCard, NFCWreatActivity.this)) { |
| | | userCardBean.setCardNumber(cardNumber); |
| | | userCardBean.setUserCode(userCode); |
| | | userCardBean.setDate(System.currentTimeMillis()); |
| | | baseDao.userCardDao().insert(userCardBean); |
| | | confromReplaceCard(replaceCardResult.getIccardRechargeRecordId(), 0); |
| | | } else { |
| | | TipUtil.show(NFCWreatActivity.this, "写卡失败,请重试"); |
| | |
| | | // 打印相关 |
| | | // setPrinterData(rechargeBean); |
| | | // startDetailActivity(rechargeBean.getUserName(), "终端写卡"); |
| | | } else { |
| | | ToastUtil.show(t.getMsg()); |
| | | } |
| | | } |
| | | }); |
| | |
| | | private void confromReplaceCard(String iccardRechargeRecordId, int writeCardStatus) { |
| | | Map<String, Object> data = new HashMap<>(); |
| | | data.put("equipCode", DeviceUtils.getSN()); |
| | | // data.put("iccardRechargeRecordId", iccardRechargeRecordId); |
| | | data.put("iccardRechargeRecordId", iccardRechargeRecordId); |
| | | //写卡状态 0 写卡成功 1 待写卡 2 写卡失败 |
| | | data.put("writeCardStatus", writeCardStatus); |
| | | |
| | | ApiManager.getInstance().requestPostLoading(this, "api/sjgg/iccard/recharge/reissueOpenCardResult", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() { |
| | | ApiManager.getInstance().requestPostLoading(this, "iccard/recharge/reissueOpenCardResult", LoginResult.class, data, new SubscriberListener<BaseResponse<LoginResult>>() { |
| | | @Override |
| | | public void onNext(BaseResponse<LoginResult> t) { |
| | | if (t.isSuccess()) { |
| | | |
| | | try { |
| | | baseDao.rechargeDao().insert(rechargeBean); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 打印相关 |
| | | setPrinterData(rechargeBean); |
| | | startDetailActivity(rechargeBean.getUserName(), "终端写卡"); |
| | | TipUtil.show(NFCWreatActivity.this, "补卡成功!", () -> { |
| | | if (UserSearchActivity.userSearchActivity != null) { |
| | | UserSearchActivity.userSearchActivity.finish(); |
| | | UserSearchActivity.userSearchActivity = null; |
| | | } |
| | | NFCWreatActivity.this.finish(); |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 补卡逻辑 |
| | | */ |
| | | private void replaceCard() { |
| | | cardNumber = NfcReadHelper.getInstence(intent, this).getCardNumber(); |
| | | if (replaceType == BaseCommon.REPLACE_NO_CARD) { |
| | | replaceCardPost("", ""); |
| | | } else if (replaceType == BaseCommon.REPLACE_HAS_CARD) { |
| | | |
| | | } |
| | | } |
| | | } |