Mr.qian 4 dni temu
rodzic
commit
2d4cf309f0

+ 3 - 2
cif-service/src/main/java/com/txz/cif/service/impl/JPushServiceImpl.java

@@ -1,5 +1,6 @@
 package com.txz.cif.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
@@ -55,10 +56,10 @@ public class JPushServiceImpl implements JPushService {
                 .body();
         
         log.info("jpush-sms-result:{}", body);
-        // "{\"code\":\"200\",\"message\":\"success\"}"
+        // "{"send_channel":"sms","message_id":"1988900596811325440"}"
         JSONObject resultJson = JSONUtil.parseObj(body);
         
-        if (resultJson.getInt("code") == 200) {
+        if (ObjectUtil.isNotEmpty(resultJson.get("message_id"))) {
             return true;
         }
         return false;

+ 9 - 7
cif-service/src/test/java/com/txz/cif/CifLocalTest.java

@@ -1,8 +1,8 @@
 package com.txz.cif;
 
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import com.txz.cif.dto.jpush.JPushSmsDTO;
-import com.txz.cif.dto.jpush.JPushTemplateDTO;
 import org.junit.jupiter.api.Test;
 
 /**
@@ -16,11 +16,13 @@ public class CifLocalTest {
     @Test
     public void test() {
         
-        JPushSmsDTO pushSmsDTO = new JPushSmsDTO();
-        pushSmsDTO.setTo("+" + "01998549097");
-        pushSmsDTO.setCode("123456");
-        pushSmsDTO.setTemplate(new JPushTemplateDTO());
+        // String body = "{\"send_channel\":\"sms\",\"message_id\":\"1988900596811325440\"}";
+        String body = "{\"code\": 3005,\"message\": \"balance not enough\"}";
+        JSONObject resultJson = JSONUtil.parseObj(body);
         
-        System.out.println(JSONUtil.toJsonStr(pushSmsDTO));
+        if (ObjectUtil.isNotEmpty(resultJson.get("message_id"))) {
+            System.out.println("success");
+            
+        }
     }
 }