Просмотр исходного кода

修改消费金额为消费接口返回的消费金额

xiari 11 месяцев назад
Родитель
Сommit
74d8cc1310

+ 6 - 5
ruoyi-server/ruoyi-server-hik/src/main/java/org/dromara/server/hik/event/handler/ConsumptionEventHandler.java

@@ -48,7 +48,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 +66,7 @@ public class ConsumptionEventHandler implements HikEventHandler {
             RemoteConsumeBo updatedRemoteBo = result.getUpdatedRemoteBo();
             String reason = "";
             BigDecimal balance = updatedRemoteBo.getBalance();
+            BigDecimal consumeMoney = updatedRemoteBo.getConsumeMoney();
             String deptName =updatedRemoteBo.getDeptName();
             if (R.isError(errorInfo)) {
                 // 应答失败
@@ -79,7 +80,7 @@ public class ConsumptionEventHandler implements HikEventHandler {
             }
 
             // 应答
-            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");
@@ -125,7 +126,7 @@ public class ConsumptionEventHandler implements HikEventHandler {
     }
 
 
-    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 +148,8 @@ public class ConsumptionEventHandler implements HikEventHandler {
             }
         }else{
             if(answerResult){
-                confirmBo.setActualPayment(consumptionEvent.getTotalPayment());
-                BigDecimal balanceBeforeDeduct = balance.multiply(new BigDecimal("100")).add(new BigDecimal(consumptionEvent.getTotalPayment()));
+                confirmBo.setActualPayment(consumeMoney.toString().split("\\.")[0]);
+                BigDecimal balanceBeforeDeduct = balance.multiply(new BigDecimal("100")).add(consumeMoney);
                 confirmBo.setBalanceBeforeDeduct(balanceBeforeDeduct.toString().split("\\.")[0]); // 未扣款前的余额,要根据余额加上扣款金额,单位为分 ,金额模式必填
             }else{
                 confirmBo.setActualPayment("0");