Commit 4319ea50 by 徐高华

自建

parent a22a34f4
......@@ -27,6 +27,7 @@ import com.gic.haoban.manage.service.entity.TabMaterialContent;
import com.gic.haoban.manage.service.service.MaterialService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.haoban.manage.service.util.QwUtils;
import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
import com.gic.weimob.common.Md5Util;
......@@ -215,11 +216,7 @@ public class MaterialServiceImpl implements MaterialService {
arr = url.split("/");
}
int count = arr.length;
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
if(qwUploadFrom==2) {
// 朋友圈上传接口
if (type == 2) {
......@@ -230,10 +227,10 @@ public class MaterialServiceImpl implements MaterialService {
url+= "?imageView2/2/w/1440/h/1080" ;
logger.info("url={}",url);
}
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), secret, CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode() , selfFlag);
jp = qywxSuiteApiService.uploadAttachment(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), url, arr[count - 1], fileType.getCode() , selfFlag , qwDTO.getUrlHost());
}else {
// 群发上传
jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), secret, CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode() , selfFlag);
jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), url, arr[count - 1], fileType.getCode() , selfFlag , qwDTO.getUrlHost());
}
if (jp.getErrorCode() == 0) {
if(from==1) {
......
......@@ -110,7 +110,7 @@ public class QywxSendServiceImpl implements QywxSendService {
JSONResponse respon = null ;
if(qwDTO.isSelf()) {
respon = qywxSuiteApiService.sendExternalMessageSelf(qwDTO.getThirdCorpid(), qwDTO.getSelfSecret(),
messageDTO);
messageDTO , qwDTO.getUrlHost());
}else {
respon = qywxSuiteApiService.sendExternalMessage(qwDTO.getThirdCorpid(), config.getWxSuiteid(),
messageDTO);
......
......@@ -48,8 +48,8 @@ import com.gic.haoban.manage.service.service.StaffClerkRelationService;
import com.gic.haoban.manage.service.service.WelcomeSendService;
import com.gic.haoban.manage.service.service.WelcomeService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.haoban.manage.service.util.EmojiFilterUtil;
import com.gic.haoban.manage.service.util.QwUtils;
import com.gic.mq.sdk.GicMQClient;
import com.gic.wechat.api.dto.qywx.welcome.QywxExternalMessageBaseDTO;
import com.gic.wechat.api.dto.qywx.welcome.QywxFileExternalBaseDTO;
......@@ -259,13 +259,9 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
private void attachmentAddImage(List<QywxExternalMessageBaseDTO> attachments, WelcomeMediaBO media, String corpid , WxEnterpriseQwDTO qwDTO) {
String mediaUrl = media.getMediaUrl();
String[] arr = mediaUrl.split("/");
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, secret,
CommonUtil.getFileByte(mediaUrl), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, QwUtils.getSecret(qwDTO, config.getWxSuiteid()),
mediaUrl, arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
log.info("欢迎语发送图片返回:{}", JSON.toJSONString(jp));
if (jp.getErrorCode() == 0) {
QywxImageExternalBaseDTO qywxImageExternalBaseDTO = new QywxImageExternalBaseDTO();
......@@ -277,13 +273,9 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
private void attachmentAddVideo(List<QywxExternalMessageBaseDTO> attachments, WelcomeMediaBO media, String corpid, WxEnterpriseQwDTO qwDTO) {
String mediaUrl = media.getMediaUrl();
String[] arr = mediaUrl.split("/");
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, secret,
CommonUtil.getFileByte(mediaUrl), arr[arr.length - 1], QywxMediaTypeEnum.VIDEO.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, QwUtils.getSecret(qwDTO, config.getWxSuiteid()),
mediaUrl, arr[arr.length - 1], QywxMediaTypeEnum.VIDEO.getCode(),selfFlag,qwDTO.getUrlHost());
log.info("欢迎语发送视频返回:{}", JSON.toJSONString(jp));
if (jp.getErrorCode() == 0) {
QywxVideoExternalBaseDTO qywxVideoExternalBaseDTO = new QywxVideoExternalBaseDTO();
......@@ -295,13 +287,9 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
private void attachmentAddFile(List<QywxExternalMessageBaseDTO> attachments, WelcomeMediaBO media, String corpid, WxEnterpriseQwDTO qwDTO) {
String mediaUrl = media.getMediaUrl();
String[] arr = mediaUrl.split("/");
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, secret,
CommonUtil.getFileByte(mediaUrl), arr[arr.length - 1], QywxMediaTypeEnum.FILE.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, QwUtils.getSecret(qwDTO, config.getWxSuiteid()),
mediaUrl, arr[arr.length - 1], QywxMediaTypeEnum.FILE.getCode(),selfFlag,qwDTO.getUrlHost());
log.info("欢迎语发送文件返回:{}", JSON.toJSONString(jp));
if (jp.getErrorCode() == 0) {
QywxFileExternalBaseDTO qywxFileExternalBaseDTO = new QywxFileExternalBaseDTO();
......@@ -372,13 +360,9 @@ public class WelcomeSendServiceImpl implements WelcomeSendService {
if (qRcodePic != null) {
String downloadUrl = qRcodePic.getPicUploadResDTO().downloadUrl;
String[] arr = downloadUrl.split("/");
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, secret,
CommonUtil.getFileByte(downloadUrl), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(corpid, QwUtils.getSecret(qwDTO, config.getWxSuiteid()),
downloadUrl, arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
log.info("欢迎语发送带参数的公众号企微二维码返回:{}", JSON.toJSONString(jp));
if (jp.getErrorCode() == 0) {
QywxImageExternalBaseDTO qywxImageExternalBaseDTO = new QywxImageExternalBaseDTO();
......
......@@ -146,7 +146,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (type == 3) {
String imgUrl = materialDTO.getImgUrl();
logger.info("【上传图片】imgUrl={}", imgUrl);
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , QwUtils.getSecret(qwDTO, config.getWxSuiteid()), CommonUtil.getFileByte(imgUrl) , qwDTO.isSelf());
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid() , QwUtils.getSecret(qwDTO, config.getWxSuiteid()), imgUrl , qwDTO.isSelf(),qwDTO.getUrlHost());
logger.info("【上传图片返回】response={}", JSON.toJSONString(response));
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl);
......@@ -154,12 +154,8 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (fileType != null) {
String[] arr = url.split("/");
int count = arr.length;
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid() , secret, CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid() , QwUtils.getSecret(qwDTO, config.getWxSuiteid()), url, arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString());
......@@ -216,7 +212,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
String imgUrl = materialDTO.getImgUrl();
String oldImgUrl = materialDTO.getImgUrl();
if (!imgUrl.equals(oldImgUrl)) {
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), CommonUtil.getFileByte(imgUrl) ,qwDTO.isSelf());
JSONResponse response = qywxSuiteApiService.uploadImage(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), imgUrl ,qwDTO.isSelf(),qwDTO.getUrlHost());
String wxImgUrl = response.getResult() == null ? "" : response.getResult().toString();
materialDTO.setWxImgUrl(wxImgUrl);
}
......@@ -224,12 +220,8 @@ public class MaterialApiServiceImpl implements MaterialApiService {
if (fileType != null && !url.equals(oldUrl)) {
String[] arr = url.split("/");
int count = arr.length;
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), secret, CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), url , arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
materialDTO.setWxLastUploadTime(new Date());
materialDTO.setMediaId(jp.getResult().toString());
......@@ -278,12 +270,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
}
String[] arr = url.split("/");
int count = arr.length;
boolean selfFlag = qwDTO.isSelf() ;
String secret = config.getWxSuiteid() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), secret, CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), url, arr[count - 1], fileType.getCode(),qwDTO.isSelf(),qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
old.setWxLastUploadTime(new Date());
old.setMediaId(jp.getResult().toString());
......@@ -460,11 +447,7 @@ public class MaterialApiServiceImpl implements MaterialApiService {
QywxMediaTypeEnum fileType = QywxMediaTypeEnum.IMAGE;
int count = arr.length;
boolean selfFlag = qwDTO.isSelf() ;
String secret = config.getWxSuiteid() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(corPid, secret, CommonUtil.getFileByte(url), arr[count - 1], fileType.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(corPid, QwUtils.getSecret(qwDTO, config.getWxSuiteid()), url, arr[count - 1], fileType.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
return jp.getResult().toString();
}
......
......@@ -20,6 +20,7 @@ import com.gic.haoban.manage.service.entity.TabMiniprogramSetting;
import com.gic.haoban.manage.service.service.MiniprogramSettingService;
import com.gic.haoban.manage.service.service.WxEnterpriseService;
import com.gic.haoban.manage.service.util.CommonUtil;
import com.gic.haoban.manage.service.util.QwUtils;
import com.gic.wechat.api.enums.QywxMediaTypeEnum;
import com.gic.wechat.api.service.qywx.QywxSuiteApiService;
......@@ -62,12 +63,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
}
String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(miniprogramSetting.getWxEnterpriseId()) ;
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), secret, CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), miniprogramSetting.getImageUrl(), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString());
......@@ -121,12 +118,8 @@ public class MiniprogramSettingServiceImpl implements MiniprogramSettingService
}
String[] arr = miniprogramSetting.getImageUrl().split("/");
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
String secret = config.getWxSuiteid() ;
boolean selfFlag = qwDTO.isSelf() ;
if(selfFlag) {
secret = qwDTO.getSelfSecret() ;
}
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), secret, CommonUtil.getFileByte(miniprogramSetting.getImageUrl()), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag);
JSONResponse jp = qywxSuiteApiService.uploadMedia(qwDTO.getThirdCorpid(), QwUtils.getSecret(qwDTO, config.getWxSuiteid()), miniprogramSetting.getImageUrl(), arr[arr.length - 1], QywxMediaTypeEnum.IMAGE.getCode(),selfFlag,qwDTO.getUrlHost());
if (jp.getErrorCode() == 0) {
miniprogramSetting.setMediaTime(date);
miniprogramSetting.setMediaId(jp.getResult().toString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment