|
|
@@ -0,0 +1,45 @@
|
|
|
+package com.mokamrp.privates.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.mokamrp.privates.service.CoralApiService;
|
|
|
+import com.mokamrp.privates.service.FileService;
|
|
|
+import com.mokamrp.privates.service.WechatApiService;
|
|
|
+import com.mokamrp.privates.utils.http.HttpUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+@Service
|
|
|
+public class WechatApiServiceImpl implements WechatApiService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public FileService fileService;
|
|
|
+
|
|
|
+ private String wechatApi = "https://api.weixin.qq.com";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建小程序跳转二维码
|
|
|
+ * @param scene
|
|
|
+ * @param page
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String BuildBoxUnlimited(String token,String scene,String page){
|
|
|
+ String url = "/wxa/getwxacodeunlimit?access_token="+token;
|
|
|
+ Map<String,String> body = new HashMap<>();
|
|
|
+ body.put("scene",scene);
|
|
|
+ body.put("page",page);
|
|
|
+ String jsonStr = JSON.toJSONString(body);
|
|
|
+ String qrcodeStr = HttpUtils.sendPost(wechatApi+url,jsonStr,"utf-8");
|
|
|
+ byte[] imageB = qrcodeStr.getBytes(StandardCharsets.UTF_16);
|
|
|
+ InputStream is = new ByteArrayInputStream(imageB);
|
|
|
+ String ossUrl = fileService.uploadIsToOss(is,".png");
|
|
|
+ return ossUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|