Your Name 3 년 전
부모
커밋
b27e1f7302
2개의 변경된 파일21개의 추가작업 그리고 11개의 파일을 삭제
  1. 17
    11
      src/main/java/com/yunzhi/marketing/common/WorkWxUtils.java
  2. 4
    0
      src/main/java/com/yunzhi/marketing/xlk/dto/VideoDTO.java

+ 17
- 11
src/main/java/com/yunzhi/marketing/common/WorkWxUtils.java 파일 보기

@@ -3,6 +3,7 @@ package com.yunzhi.marketing.common;
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.yunzhi.marketing.config.WorkConfig;
5 5
 import lombok.extern.slf4j.Slf4j;
6
+import me.chanjar.weixin.common.error.WxErrorException;
6 7
 import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
7 8
 import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
8 9
 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,19 +34,24 @@ public class WorkWxUtils {
33 34
             throw new Exception("房间号或者人员openid不能为空");
34 35
         }
35 36
 
36
-        String url = "/cgi-bin/living/get_living_code";
37
-        JSONObject params = new JSONObject();
38
-        params.put("livingid", livingid);
39
-        params.put("openid", openid);
37
+        try {
38
+            String url = wxCpService.getWxCpConfigStorage().getApiUrl("/cgi-bin/living/get_living_code");
39
+            JSONObject params = new JSONObject();
40
+            params.put("livingid", livingid);
41
+            params.put("openid", openid);
40 42
 
41
-        String response = wxCpService.post(url, params.toJSONString());
42
-        JSONObject result = JSONObject.parseObject(response);
43
-
44
-        String errmsg = result.getString("errmsg");
45
-        if ("ok".equals(errmsg)) {
43
+            String response = wxCpService.post(url, params.toJSONString());
44
+            JSONObject result = JSONObject.parseObject(response);
46 45
             return result.getString("living_code");
47
-        } else {
48
-            throw new Exception(String.format("获取直播凭证失败: %s", errmsg));
46
+        } catch (WxErrorException e) {
47
+            if (90601 == e.getError().getErrorCode()) {
48
+                throw new Exception("直播房间不存在");
49
+            } else {
50
+                throw new Exception(String.format("获取直播凭证失败: %s", e.getError().getErrorMsg()));
51
+            }
52
+        } catch (Exception e) {
53
+            e.printStackTrace();
54
+            throw e;
49 55
         }
50 56
     }
51 57
 }

+ 4
- 0
src/main/java/com/yunzhi/marketing/xlk/dto/VideoDTO.java 파일 보기

@@ -60,4 +60,8 @@ public class VideoDTO implements Serializable {
60 60
     @TableField("WEIGHT")
61 61
     private Integer weight;
62 62
 
63
+    /**
64
+     * 是否新房
65
+     */
66
+    private Boolean isNewHouse;
63 67
 }