@@ -209,7 +209,7 @@ public class BluetoothDialog { | |||
if ("0".equals(s2 + "")) { | |||
String strStatus = MethodManager.ReadCard();//获取卡信息 | |||
Log.e("okhttp", "卡对象信息:" + BoxManagers.mCardInfoBean + | |||
Log.e("okhttp", "卡对象信息:" + BoxManagers.mCardInfoBean.getCard_No() + | |||
"OBU号:" + status + "车辆信息:" + BoxManagers.mDecryptVehicleBean); | |||
mResult.BluetoothLinkIsSuccessful(BoxManagers.gerBoxManager()); //回调成功 | |||
autoDismiss(); |
@@ -0,0 +1,199 @@ | |||
package com.huntersun.vkyes.etcopencard.project.bluetooth; | |||
import android.annotation.SuppressLint; | |||
import com.google.gson.Gson; | |||
import com.hjq.toast.ToastUtils; | |||
import com.huntersun.vky.obublelib.box.BoxManagers; | |||
import com.huntersun.vkyes.etcopencard.project.api.Api; | |||
import com.huntersun.vkyes.etcopencard.project.api.Converter; | |||
import com.huntersun.vkyes.etcopencard.project.api.MyRetrofit; | |||
import com.huntersun.vkyes.etcopencard.project.api.RequestParameters; | |||
import com.huntersun.vkyes.etcopencard.project.api.Result; | |||
import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; | |||
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | |||
import com.huntersun.vkyes.etcopencard.project.api.bean.SendTheVerificationCodeBean; | |||
import com.huntersun.vkyes.etcopencard.project.utils.FunHelper; | |||
import com.huntersun.vkyes.etcopencard.src.app.AppActivity; | |||
import retrofit2.Response; | |||
/** | |||
* Date :2023-03-23 | |||
* Description:圈存检测 | |||
*/ | |||
public class BluetoothLoop { | |||
private AppActivity mContext; | |||
private LoopCallback callback; | |||
private String cardId; //链接蓝牙读取新卡号 | |||
private String tradeType; | |||
private String orderId; | |||
private String money; | |||
public BluetoothLoop(AppActivity mContext,String tradeType, String orderId, String money,LoopCallback callback) { | |||
this.mContext = mContext; | |||
this.callback = callback; | |||
this.tradeType = tradeType; | |||
this.orderId = orderId; | |||
this.money = money; | |||
} | |||
/** | |||
* 圈存检测-链接蓝牙 | |||
*/ | |||
public void loopWithOpenBluetooth() { | |||
mContext.bluetoothLink(new AppActivity.Currency() { | |||
@Override | |||
public void success() { | |||
cardId = BoxManagers.mCardInfoBean.getCard_No(); | |||
loopDetection(); | |||
} | |||
}); | |||
} | |||
/** | |||
* 圈存检测 | |||
* 正常(无半条流水)-> 圈存申请(圈存申请 orderNum) -> 圈存确认 | |||
* 异常(有半条流水) -> 圈存修复 -> 圈存申请 -> 圈存确认 | |||
*/ | |||
public void loopDetection() { | |||
SendTheVerificationCodeBean bean = new SendTheVerificationCodeBean(); | |||
bean.setCardId(cardId); | |||
bean.setFee(Long.parseLong(money)); //充值金额 | |||
bean.setPreBalance(0L); //之前的卡内余额 | |||
bean.setTradeType(tradeType); //交易类型 | |||
bean.setStaffId(bean.getOpId()); | |||
RequestParameters parameters = new RequestParameters(IFCode.IFCODE69, new Gson().toJson(bean)); | |||
new MyRetrofit().getRetrofit().create(Api.class).message2(parameters).enqueue(new Converter<Result>(mContext, "圈存初始化中...") { | |||
@Override | |||
protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | |||
if ("1".equals(bizContent.getChargeStatus())) {//圈存检测正常(无半条流水)-圈存 | |||
loopApply(bizContent); | |||
} else if ("2".equals(bizContent.getChargeStatus())) { //圈存检测异常(有半条流水) | |||
loopRepair(bizContent); | |||
} | |||
} | |||
}); | |||
} | |||
/** | |||
* 圈存申请 | |||
*/ | |||
private void loopApply(ResultBean.BizContent bizContent) { | |||
if (!bizContent.getCardId().equals(cardId)) { | |||
ToastUtils.show("卡信息与识别卡信息不符!"); | |||
return; | |||
} | |||
SendTheVerificationCodeBean bean = new SendTheVerificationCodeBean(); | |||
bean.setCardId(cardId); //卡号 | |||
bean.setFee(Long.parseLong(money)); //充值金额 | |||
bean.setPreBalance((long) (BoxManagers.mCardInfoBean.getMoney() * 100)); //交易前卡额 | |||
bean.setTradeType(tradeType); //交易类型 | |||
//bean.setRechargeId(bizContent.getRechargeId()); //设置充值Id | |||
bean.setCommand(bizContent.getCommand()); //指令 | |||
bean.setCosResponse(BluetoothWriteCardWriteTab.writeCard(bizContent.getCommand()) + ""); //初始化结果 | |||
bean.setOrderId(orderId); | |||
bean.setStaffId(bean.getOpId()); | |||
RequestParameters parameters = new RequestParameters(IFCode.IFCODE70, new Gson().toJson(bean)); | |||
new MyRetrofit().getRetrofit().create(Api.class).message2(parameters) | |||
.enqueue(new Converter<Result>(mContext, "圈存申请中...") { | |||
@Override | |||
protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent1) { | |||
if ("1".equals(bizContent1.getCommandType())) { | |||
BluetoothWriteCardWriteTab.writeCard(bizContent.getCommand()); | |||
loopApply(bizContent1); | |||
return; | |||
} | |||
loopConfirm(bizContent1,true); | |||
} | |||
}); | |||
} | |||
/** | |||
* 圈存修复 | |||
*/ | |||
private void loopRepair(ResultBean.BizContent bizContent) { | |||
if (!bizContent.getCardId().equals(cardId)) { | |||
ToastUtils.show("卡信息与识别卡信息不符!"); | |||
return; | |||
} | |||
SendTheVerificationCodeBean bean = new SendTheVerificationCodeBean(); | |||
bean.setCommand(bizContent.getCommand()); //修复初始化的指令 | |||
bean.setCosResponse(BluetoothWriteCardWriteTab.writeCard(bizContent.getCommand()) + ""); //修复初始化结果 | |||
bean.setRechargeId(bizContent.getRechargeId()); //充值流水号 | |||
bean.setCardVersion(""); //卡版本 | |||
bean.setStaffId(bean.getOpId()); | |||
RequestParameters parameters = new RequestParameters(IFCode.IFCODE71, new Gson().toJson(bean)); | |||
new MyRetrofit().getRetrofit().create(Api.class).message2(parameters).enqueue(new Converter<Result>() { | |||
@SuppressLint("LogNotTimber") | |||
@Override | |||
protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | |||
/* | |||
* 1-圈存修复COS指令Response信息不足,重新进行修复初始化 | |||
* 2-圈存修复完成,已充值成功 | |||
* 3-圈存修复 , 写卡失败,需要重新进行圈存 | |||
*/ | |||
switch (bizContent.getFixStatus()) { | |||
case "1": //圈存修复 | |||
loopRepair(bizContent); | |||
break; | |||
case "2": //圈存确认 | |||
loopConfirm(bizContent, false); | |||
break; | |||
case "3": //圈存申请 | |||
loopApply(bizContent); | |||
break; | |||
} | |||
} | |||
}); | |||
} | |||
/** | |||
* 圈存确认 | |||
*/ | |||
private void loopConfirm(ResultBean.BizContent bizContent, boolean start) { | |||
if (!bizContent.getCardId().equals(cardId)) { | |||
ToastUtils.show("卡信息与识别卡信息不符!"); | |||
return; | |||
} | |||
SendTheVerificationCodeBean bean = new SendTheVerificationCodeBean(); | |||
if (start) { | |||
bean.setCommand(bizContent.getCommand()); //指令 | |||
bean.setCosResponse(BluetoothWriteCardWriteTab.writeCard(bizContent.getCommand()) + ""); //初始化结果 | |||
} else { | |||
bean.setCommand(bizContent.getCommand()); //指令 | |||
bean.setCosResponse("9000"); //初始化结果 | |||
} | |||
//bean.setRechargeId(bizContent.getRechargeId()); //充值流水号 | |||
bean.setPaidAmount(100L); //实收金额 | |||
bean.setGiftAmount("0"); //赠送金额 | |||
bean.setStaffId(bean.getOpId()); | |||
RequestParameters parameters = new RequestParameters(IFCode.IFCODE72, new Gson().toJson(bean)); | |||
new MyRetrofit().getRetrofit().create(Api.class).message2(parameters).enqueue(new Converter<Result>(mContext, "圈存确认中...") { | |||
@Override | |||
protected void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | |||
if (callback != null) { | |||
callback.loopSuccess(bizContent); | |||
} | |||
} | |||
@Override | |||
public void onError(String err, Response<Result> resp) { | |||
super.onError(err, resp); | |||
if (callback != null){ | |||
callback.loopFail(); | |||
} | |||
} | |||
}); | |||
} | |||
public interface LoopCallback { | |||
void loopSuccess(ResultBean.BizContent bizContent); | |||
void loopFail(); | |||
} | |||
} |
@@ -11,6 +11,7 @@ import com.huntersun.vkyes.etcopencard.project.api.MyRetrofit; | |||
import com.huntersun.vkyes.etcopencard.project.api.Result; | |||
import com.huntersun.vkyes.etcopencard.project.api.bean.IFCode; | |||
import com.huntersun.vkyes.etcopencard.project.api.bean.ResultBean; | |||
import com.huntersun.vkyes.etcopencard.project.bluetooth.BluetoothLoop; | |||
import com.huntersun.vkyes.etcopencard.project.dialog.ConfirmDialog; | |||
import com.huntersun.vkyes.etcopencard.project.tool.Utils; | |||
import com.huntersun.vkyes.etcopencard.project.ui.adapter.BalanceReplacementAdapter; | |||
@@ -66,16 +67,18 @@ public class BalanceReplacementStep2Activity extends AppActivity implements OnRe | |||
adapter.setOnItemClickListener(new BalanceReplacementAdapter.OnItemClickListener() { | |||
@Override | |||
public void doItemClick(ResultBean.BizContent bizContent) { | |||
if (bizContent.refundType.equals("GLYQR")){//余额补领 | |||
new Utils().showMessDialog(getActivity(), "是否确认申请余额补领", new Utils.dialogCallback() { | |||
@Override | |||
public void onConfirm(BaseDialog dialog) { | |||
applyBalanceReplace(bizContent.getId()); | |||
} | |||
}); | |||
}else{//圈存 | |||
toLoop(bizContent.getId()); | |||
if (!bizContent.refundType.equals("GLYQR")){//圈存 | |||
//TODO 测试 金额应该从后端取 | |||
toLoop(bizContent.getId(),"100"); | |||
return; | |||
} | |||
new Utils().showMessDialog(getActivity(), "是否确认申请余额补领", new Utils.dialogCallback() { | |||
@Override | |||
public void onConfirm(BaseDialog dialog) { | |||
applyBalanceReplace(bizContent.getId()); | |||
} | |||
}); | |||
} | |||
}); | |||
} | |||
@@ -89,15 +92,16 @@ public class BalanceReplacementStep2Activity extends AppActivity implements OnRe | |||
/** | |||
* 申请余额补领 | |||
* @param id | |||
* @param orderId 退费信息编号 | |||
*/ | |||
private void applyBalanceReplace(String id){ | |||
private void applyBalanceReplace(String orderId){ | |||
Map<String, String> params = new HashMap<>(); | |||
params.put("id", id); | |||
params.put("orderId", orderId); | |||
MyRetrofit.newInstance(IFCode.IFCODE918, params, new MyRetrofit.ReturnResult() { | |||
@Override | |||
public void onSuccess(ResultBean resultBean, ResultBean.BizContent bizContent) { | |||
toLoop(id); | |||
//TODO 金额是测试的 要从后端取 | |||
toLoop(bizContent.getOrderId(),"100"); | |||
} | |||
@Override | |||
@@ -111,20 +115,6 @@ public class BalanceReplacementStep2Activity extends AppActivity implements OnRe | |||
}); | |||
} | |||
/** | |||
* 补领单号 | |||
* @param replId | |||
*/ | |||
private void toLoop(String replId){ | |||
//TODO 执行圈存 | |||
toast("执行圈存操作"); | |||
Bundle bundle = new Bundle(); | |||
bundle.putString("from","2"); | |||
jumpToPage(CommonDealSuccessActivity.class,bundle); | |||
finish(); | |||
} | |||
/* | |||
* 获取列表 | |||
*/ | |||
@@ -154,6 +144,30 @@ public class BalanceReplacementStep2Activity extends AppActivity implements OnRe | |||
}); | |||
} | |||
/** | |||
* 补领单号 | |||
* @param id | |||
*/ | |||
private void toLoop(String id,String money){ | |||
toast("申请补领通过,请执行圈存操作"); | |||
BluetoothLoop bluetoothLoop = new BluetoothLoop(this, "4", id, money, new BluetoothLoop.LoopCallback() { | |||
@Override | |||
public void loopSuccess(ResultBean.BizContent bizContent) { | |||
Bundle bundle = new Bundle(); | |||
bundle.putString("from","2"); | |||
jumpToPage(CommonDealSuccessActivity.class,bundle); | |||
finish(); | |||
} | |||
@Override | |||
public void loopFail() { | |||
toast("圈存失败,请尝试重试!"); | |||
getList(); | |||
} | |||
}); | |||
bluetoothLoop.loopWithOpenBluetooth(); | |||
} | |||
@Override | |||
public StatusLayout getStatusLayout() { | |||
return binding.hlStatusHint; |
@@ -20,6 +20,7 @@ public class PayTheArrearsStep0Activity extends AppActivity { | |||
private ActivityPayTheArrearsStep0Binding binding; | |||
private ResultBean.BizContent curBizContent; | |||
private String curVehicleId; | |||
@Override | |||
protected View getLayoutView() { | |||
@@ -43,6 +44,11 @@ public class PayTheArrearsStep0Activity extends AppActivity { | |||
binding.LLSearchResult.setVisibility(View.GONE); | |||
binding.LLBottom.setVisibility(View.GONE); | |||
} | |||
@Override | |||
public void onVehicleId(String vehicleId) { | |||
curVehicleId = vehicleId; | |||
} | |||
}); | |||
binding.btnNext.setOnClickListener(new View.OnClickListener() { | |||
@@ -51,6 +57,7 @@ public class PayTheArrearsStep0Activity extends AppActivity { | |||
public void onClick(View view) { | |||
Bundle bundle = new Bundle(); | |||
bundle.putString("json", JSON.toJSONString(curBizContent)); | |||
bundle.putString("vehicleId", curVehicleId); | |||
jumpToPage(PayTheArrearsStep1Activity.class, bundle); | |||
} | |||
}); |
@@ -42,6 +42,9 @@ public class PayTheArrearsStep1Activity extends AppActivity implements OnRefres | |||
private ActivityPayTheArrearsStep1Binding binding; | |||
private PayTheArrearsAdapter.INOnPayTheArrearsClick inOnPayTheArrearsClick; | |||
private ResultBean.BizContent curBizContent; | |||
private String curVehicleId; | |||
@Override | |||
protected View getLayoutView() { | |||
binding = ActivityPayTheArrearsStep1Binding.inflate(getLayoutInflater()); | |||
@@ -53,6 +56,12 @@ public class PayTheArrearsStep1Activity extends AppActivity implements OnRefres | |||
@Override | |||
protected void initView() { | |||
curVehicleId = getIntent().getStringExtra("vehicleId"); | |||
String json = getIntent().getStringExtra("json"); | |||
if (!FunHelper.isEmpty(json)){ | |||
curBizContent = JSON.parseObject(json,ResultBean.BizContent.class); | |||
} | |||
inOnPayTheArrearsClick = this; | |||
adapter = new PayTheArrearsAdapter(this); | |||
adapter.setOnPayTheArrearsClick(inOnPayTheArrearsClick); |
@@ -472,4 +472,13 @@ public class FunHelper { | |||
return df.format(bg.doubleValue()); | |||
} | |||
/* | |||
* 元转分,确保price保留两位有效数字 | |||
* | |||
* @return | |||
*/ | |||
public static String changeY2F(String price) { | |||
return String.valueOf(BigDecimal.valueOf(Double.parseDouble(price)) | |||
.multiply(new BigDecimal(100)).longValue()); | |||
} | |||
} |
@@ -38,7 +38,7 @@ public class ValidatorUtils { | |||
/* | |||
* 正则表达式:校验密码 | |||
*/ | |||
private static final String REGEX_PASSWORD = ""; | |||
private static final String REGEX_PASSWORD = "^(?=.*[0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[`~!@#$%^&*()_\\-+=<>?:\"{}|,.\\/;'\\\\[\\]·~!@#¥%……&*()——\\-+={}|《》?:“”【】、;‘',。、])[0-9a-zA-Z!`~!@#$%^&*()_\\-+=<>?:\"{}|,.\\/;'\\\\[\\]·~!@#¥%……&*()——\\-+={}|《》?:“”【】、;‘',。、]{10,20}$"; | |||
/* | |||
* 禁止实例化. |