Browse Source

爱奇艺

小么熊🐻 3 năm trước cách đây
mục cha
commit
d8606a2c89

+ 93 - 0
zzjs-admin/src/test/java/com/miaxis/test/AiTest.java

@@ -0,0 +1,93 @@
+package com.miaxis.test;
+
+import com.miaxis.ZzjsApplication;
+import com.miaxis.common.config.WaiConfig;
+import com.miaxis.common.sms.MD5Utils;
+import com.miaxis.feign.dto.Ai;
+import com.miaxis.feign.service.IAiService;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+@SpringBootTest(classes = ZzjsApplication.class)
+@RunWith(SpringRunner.class)
+public class AiTest {
+
+    @Autowired
+    private IAiService aiService;
+    @Autowired
+    private WaiConfig waiConfig;
+
+    private static String appid = "7629";
+    private static String secret = "cce08fcab10ff96a863892bb6e396a9e";
+
+    public static String getSign(Map<String, Object> params,String client_secret) {
+        Map<String, Object> sortMap = new TreeMap<String, Object>();
+        sortMap.putAll(params);
+        // 以k1v1k2v2...方式拼接参数
+        StringBuilder builder = new StringBuilder();
+        for (Map.Entry<String, Object> s : sortMap.entrySet()) {
+            String k = s.getKey();
+            Object v = s.getValue();
+            builder.append(k).append(v);
+        }
+//        if (!sortMap.isEmpty()) {
+//            builder.deleteCharAt(builder.length() - 1);
+//        }
+        builder.append(client_secret);
+//        builder.insert(0,client_secret);
+        return builder.toString();
+    }
+
+    @Test
+    public void test() throws Exception {
+        long timeLong = System.currentTimeMillis();
+        String timestamp = String.valueOf(timeLong/1000);
+        Ai ai = new Ai();
+
+        //公共请救参数
+        ai.setAppid(waiConfig.getAppid());
+        ai.setC_account("15060063160");
+        ai.setFormat("json");
+        ai.setMerchant_id("order01");
+        ai.setNotify_url("http://218.85.55.253:38080/open-api/film/notify/aiqiyiOrderNotify");
+        ai.setTime(timestamp);
+        //sign 加密
+        Map<String,Object> param = new HashMap<String,Object>();
+        //公共参数
+        param.put("appid",ai.getAppid());
+        param.put("c_account",ai.getC_account());
+        param.put("format",ai.getFormat());
+        param.put("merchant_id",ai.getMerchant_id());
+        param.put("notify_url",ai.getNotify_url());
+        param.put("time",ai.getTime());
+
+        String sign = getSign(param,waiConfig.getSecret());
+        System.out.println(sign);
+        String md5 = MD5Utils.MD5Encode(sign);
+        ai.setSign(md5);
+
+        String str = aiService.rechargeAiMonth(ai);
+        System.out.println(str);
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 2 - 3
zzjs-common/src/main/java/com/miaxis/common/config/WaiConfig.java

@@ -9,7 +9,6 @@ import org.springframework.stereotype.Component;
 @ConfigurationProperties(prefix = "wai")
 public class WaiConfig {
 
-    private String clientId;
-    private String clientSecret;
-    private String pid;
+    private String appid;
+    private String secret;
 }

+ 15 - 0
zzjs-service/src/main/java/com/miaxis/feign/dto/Ai.java

@@ -0,0 +1,15 @@
+package com.miaxis.feign.dto;
+
+import lombok.Data;
+
+@Data
+public class Ai {
+    String appid;
+    String c_account;
+    String format;
+    String merchant_id;
+    String notify_url;
+    String sign;
+    String time;
+
+}

+ 25 - 0
zzjs-service/src/main/java/com/miaxis/feign/service/IAiService.java

@@ -0,0 +1,25 @@
+package com.miaxis.feign.service;
+
+
+import com.miaxis.common.config.FeignConfig;
+import com.miaxis.feign.dto.Ai;
+import com.miaxis.feign.dto.Wa;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.PostMapping;
+
+/**
+ *
+ * 电影接口测试
+ */
+@FeignClient(name="aiService",
+        url = "https://yspm.api.storeapi.net",configuration = FeignConfig.class)
+@Component
+public interface IAiService {
+    @PostMapping(value = "/api/79/197",
+            consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+    String rechargeAiMonth(Ai ai);
+
+
+}