Sfoglia il codice sorgente

bugfix:content过长导致取消交易

xiari 9 mesi fa
parent
commit
a632eab970

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

@@ -181,9 +181,9 @@ public class ConsumptionEventHandler implements HikEventHandler {
         if (!answerResult) {
             broadcastVoice = isCountMode ? "刷卡失败" : "支付失败";
             // 提示刷卡失败的原因
-            if (StringUtils.isNotBlank(reason) && reason.length() > 30) {
+            if (StringUtils.isNotBlank(reason) && reason.length() > 10) {
                 log.info("海康消费失败原因:{}", reason);
-                newReason = reason.substring(0, 30);
+                newReason = reason.substring(0, 10) + "...";
             }
             broadcastVoice += newReason;
             confirmBo.setReason("platformException");
@@ -194,11 +194,15 @@ public class ConsumptionEventHandler implements HikEventHandler {
           这可以显示刷卡人的信息,比如姓名,部门等
          */
         ConsumptionEventConfirmBo.ContentInfo contentInfo = new ConsumptionEventConfirmBo.ContentInfo();
-        contentInfo.setTitle(consumptionEvent.getName());
-        contentInfo.setContent(deptName);
+        if(StringUtils.isNotBlank(consumptionEvent.getName()) && consumptionEvent.getName().length() > 10){
+            contentInfo.setTitle(consumptionEvent.getName().substring(0, 10) + "...");
+        }
+        if(StringUtils.isNotBlank(deptName) && deptName.length() > 10){
+            contentInfo.setContent(deptName.substring(0, 10) + "...");
+        }
         if (!answerResult) {
-            contentInfo.setTitle(consumptionEvent.getName() + "  " + deptName);
-            contentInfo.setContent("失败原因:" + newReason);
+            contentInfo.setTitle("");
+            contentInfo.setContent(newReason);
         }
         confirmBo.setContentInfo(contentInfo);