|
|
@@ -7,6 +7,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
import org.dromara.common.core.domain.model.ErrorInfo;
|
|
|
import org.dromara.common.core.enums.CreditTypeEnum;
|
|
|
+import org.dromara.common.core.enums.SystemUseTypeEnum;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.consume.api.RemoteConsumeService;
|
|
|
import org.dromara.consume.api.domain.bo.RemoteConsumeBo;
|
|
|
@@ -48,7 +49,7 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
if (termVo == null) {
|
|
|
log.error("消费机交易记录事件,设备信息为空,mac:{}, 不存在系统中", receive.getMacAddress());
|
|
|
// 直接应答失败
|
|
|
- return answerEvent(consumptionEvent, false,null, "设备未注册", "");
|
|
|
+ return answerEvent(consumptionEvent, false,null, null, "设备未注册", "");
|
|
|
}
|
|
|
/*
|
|
|
* 消费机 交易预处理请求事件上报
|
|
|
@@ -66,6 +67,8 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
RemoteConsumeBo updatedRemoteBo = result.getUpdatedRemoteBo();
|
|
|
String reason = "";
|
|
|
BigDecimal balance = updatedRemoteBo.getBalance();
|
|
|
+ BigDecimal consumeMoney = updatedRemoteBo.getConsumeMoney();
|
|
|
+// BigDecimal consumeMoney = new BigDecimal("10");
|
|
|
String deptName =updatedRemoteBo.getDeptName();
|
|
|
if (R.isError(errorInfo)) {
|
|
|
// 应答失败
|
|
|
@@ -75,11 +78,9 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
if(data != null){
|
|
|
reason = data.getMessage();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
// 应答
|
|
|
- return answerEvent(consumptionEvent, bussiRs, balance, reason,deptName);
|
|
|
+ return answerEvent(consumptionEvent, bussiRs, balance,consumeMoney, reason,deptName);
|
|
|
}else if(TRANSACTION_CONFIRMING_REQUEST.equals(consumptionEvent.getMinor())){
|
|
|
HashMap<String, Object> rs = new HashMap<>(1);
|
|
|
rs.put("result", "success");
|
|
|
@@ -120,12 +121,13 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
receive.getDateTime(), consumptionEvent.getSerialNo(), consumptionEvent.getTotalPayment(), receive.getMacAddress());
|
|
|
remoteBo.setCardNo(0L);
|
|
|
remoteBo.setStatusFlag(4);
|
|
|
+ remoteBo.setUseType(SystemUseTypeEnum.CONSUME.code());
|
|
|
remoteBo.setCreditType(CreditTypeEnum.TERM_CONSUME.code());
|
|
|
return remoteBo;
|
|
|
}
|
|
|
|
|
|
|
|
|
- public Map<String, Object> answerEvent(ConsumptionEventDetail consumptionEvent, boolean answerResult, BigDecimal balance, String reason,String deptName)
|
|
|
+ public Map<String, Object> answerEvent(ConsumptionEventDetail consumptionEvent, boolean answerResult, BigDecimal balance,BigDecimal consumeMoney, String reason,String deptName)
|
|
|
{
|
|
|
ConsumptionEventConfirmBo confirmBo = new ConsumptionEventConfirmBo();
|
|
|
confirmBo.setSerialNo(consumptionEvent.getSerialNo());
|
|
|
@@ -147,8 +149,9 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
}
|
|
|
}else{
|
|
|
if(answerResult){
|
|
|
- confirmBo.setActualPayment(consumptionEvent.getTotalPayment());
|
|
|
- BigDecimal balanceBeforeDeduct = balance.multiply(new BigDecimal("100")).add(new BigDecimal(consumptionEvent.getTotalPayment()));
|
|
|
+ BigDecimal con = consumeMoney.multiply(new BigDecimal("100"));
|
|
|
+ confirmBo.setActualPayment(con.toString().split("\\.")[0]);
|
|
|
+ BigDecimal balanceBeforeDeduct = balance.multiply(new BigDecimal("100")).add(con);
|
|
|
confirmBo.setBalanceBeforeDeduct(balanceBeforeDeduct.toString().split("\\.")[0]); // 未扣款前的余额,要根据余额加上扣款金额,单位为分 ,金额模式必填
|
|
|
}else{
|
|
|
confirmBo.setActualPayment("0");
|
|
|
@@ -157,10 +160,15 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
}
|
|
|
|
|
|
String broadcastVoice = isCountMode ? "刷卡成功":"支付成功";
|
|
|
+ String newReason = reason;
|
|
|
if(!answerResult){
|
|
|
broadcastVoice = isCountMode ? "刷卡失败":"支付失败";
|
|
|
// 提示刷卡失败的原因
|
|
|
- broadcastVoice += reason;
|
|
|
+ if(StringUtils.isNotBlank(reason) && reason.length() > 30){
|
|
|
+ log.info("海康消费失败原因:{}", reason);
|
|
|
+ newReason = reason.substring(0,30);
|
|
|
+ }
|
|
|
+ broadcastVoice += newReason;
|
|
|
confirmBo.setReason("platformException");
|
|
|
}
|
|
|
confirmBo.setCustomTTSBroadcastVoice(broadcastVoice);
|
|
|
@@ -173,7 +181,7 @@ public class ConsumptionEventHandler implements HikEventHandler {
|
|
|
contentInfo.setContent(deptName);
|
|
|
if(!answerResult){
|
|
|
contentInfo.setTitle(consumptionEvent.getName()+ " "+deptName);
|
|
|
- contentInfo.setContent("失败原因:"+reason);
|
|
|
+ contentInfo.setContent("失败原因:"+ newReason);
|
|
|
}
|
|
|
confirmBo.setContentInfo(contentInfo);
|
|
|
|