Browse Source

微信第三方平台-优化

master
zxc 5 years ago
parent
commit
da4d9b9800
  1. 18
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java
  2. 14
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java
  3. 14
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java
  4. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  5. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java
  6. 65
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java
  7. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java
  8. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  9. 16
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java
  10. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  11. 18
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml
  12. 14
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml
  13. 14
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml

18
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CodeAuditRecordFormDTO.java

@ -42,12 +42,12 @@ public class CodeAuditRecordFormDTO implements Serializable {
/**
* 小程序的原始 ID
*/
private String toUserName;
private String ToUserName;
/**
* 发送方帐号一个 OpenID此时发送方是系统帐号
*/
private String fromUserName;
private String FromUserName;
/**
* 消息创建时间 整型时间戳
@ -57,7 +57,7 @@ public class CodeAuditRecordFormDTO implements Serializable {
/**
* 消息类型 event
*/
private String msgType;
private String MsgType;
/**
* 事件类型
@ -65,32 +65,32 @@ public class CodeAuditRecordFormDTO implements Serializable {
weapp_audit_fail审核不通过
weapp_audit_delay审核延后
*/
private String event;
private String Event;
/**
* 审核成功时的时间戳
*/
private Date succTime;
private Date SuccTime;
/**
* 审核不通过的时间戳
*/
private Date failTime;
private Date FailTime;
/**
* 审核延后时的时间戳
*/
private Date delayTime;
private Date DelayTime;
/**
* 审核不通过的原因
*/
private String reason;
private String Reason;
/**
* 审核不通过的截图示例 | 分隔的 media_id 的列表可通过获取永久素材接口拉取截图内容
*/
private String screenShot;
private String ScreenShot;
/**
* 删除状态

14
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/MiniInfoFormDTO.java

@ -28,32 +28,32 @@ public class MiniInfoFormDTO implements Serializable {
/**
* 昵称
*/
private String nickName;
private String nick_name;
/**
* 头像
*/
private String headImg;
private String head_img;
/**
* 小程序类型 默认为 0
*/
private String serviceTypeInfo;
private String service_type_info;
/**
* 小程序认证类型 小程序认证类型
*/
private String verifyTypeInfo;
private String verify_type_info;
/**
* 原始 ID
*/
private String userName;
private String user_name;
/**
* 主体名称
*/
private String principalName;
private String principal_name;
/**
* 账号介绍
@ -63,7 +63,7 @@ public class MiniInfoFormDTO implements Serializable {
/**
* 二维码图片的 URL
*/
private String qrcodeUrl;
private String qrcode_url;
private Integer delFlag = 0;

14
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PaInfoFormDTO.java

@ -28,19 +28,19 @@ public class PaInfoFormDTO implements Serializable {
/**
* 昵称
*/
private String nickName;
private String nick_name;
/**
* 头像
*/
private String headImg;
private String head_img;
/**
* 公众号类型 0订阅号
1由历史老帐号升级后的订阅号
2服务号
*/
private String serviceTypeInfo;
private String service_type_info;
/**
* 公众号认证类型 -1未认证
@ -51,17 +51,17 @@ public class PaInfoFormDTO implements Serializable {
4已资质认证通过还未通过名称认证但通过了新浪微博认证
5已资质认证通过还未通过名称认证但通过了腾讯微博认证
*/
private String verifyTypeInfo;
private String verify_type_info;
/**
* 原始ID
*/
private String userName;
private String user_name;
/**
* 主体名称
*/
private String principalName;
private String principal_name;
/**
* 公众号所设置的微信号可能为空 公众号所设置的微信号可能为空
@ -71,7 +71,7 @@ public class PaInfoFormDTO implements Serializable {
/**
* 二维码图片的 URL
*/
private String qrcodeUrl;
private String qrcode_url;
/**
* 删除状态 0正常1删除

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -77,6 +77,8 @@ public interface ModuleConstant {
String DELAY = "delay";
String AUDIT_SUCCESS = "audit_success";
String AUDIT_FAILED = "audit_failed";
String XML = "xml";
String CREATE_TIME = "CreateTime";
int FORTY_THOUSAND_AND_THIRTEEN = 40013;
int EIGHTY_NINE_THOUSAND = 89000;

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java

@ -1,6 +1,6 @@
package com.epmet.controller;
import com.epmet.exception.AesException;
import com.epmet.mpaes.AesException;
import com.epmet.service.WarrantService;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException;

65
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/exception/AesException.java

@ -1,65 +0,0 @@
package com.epmet.exception;
/**
* @Author zxc
* @CreateTime 2020/7/6 10:03
*/
@SuppressWarnings("serial")
public class AesException extends Exception {
/*public final static int OK = 0;
public final static int ValidateSignatureError = -40001;
public final static int ParseXmlError = -40002;
public final static int ComputeSignatureError = -40003;
public final static int IllegalAesKey = -40004;
public final static int ValidateCorpidError = -40005;
public final static int EncryptAESError = -40006;
public final static int DecryptAESError = -40007;
public final static int IllegalBuffer = -40008;
public final static int EncodeBase64Error = -40009;
public final static int DecodeBase64Error = -40010;
public final static int GenReturnXmlError = -40011;
private int code;
private static String getMessage(int code) {
switch (code) {
case ValidateSignatureError:
return "签名验证错误";
case ParseXmlError:
return "xml解析失败";
case ComputeSignatureError:
return "sha加密生成签名失败";
case IllegalAesKey:
return "SymmetricKey非法";
case ValidateCorpidError:
return "corpid校验失败";
case EncryptAESError:
return "aes加密失败";
case DecryptAESError:
return "aes解密失败";
case IllegalBuffer:
return "解密后得到的buffer非法";
case EncodeBase64Error:
return "base64加密错误";
case DecodeBase64Error:
return "base64解密错误";
case GenReturnXmlError:
return "xml生成失败";
default:
return null; // cannot be
}
}
public int getCode() {
return code;
}
public AesException(int code) {
super(getMessage(code));
this.code = code;
}
*/
}

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/WarrantService.java

@ -1,8 +1,7 @@
package com.epmet.service;
import com.epmet.exception.AesException;
import com.epmet.mpaes.AesException;
import org.dom4j.DocumentException;
import org.springframework.web.bind.annotation.PathVariable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

3
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java

@ -408,7 +408,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId);
jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,authAppId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO, JSON.toJSONString(jsonObject)).getData();
String componentAccessToken = redisThird.getComponentAccessToken();
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData();
Map<String,Map> map = JSON.parseObject(data, Map.class);
Map authorizerInfo = map.get(ModuleConstant.AUTHORIZER_INFO);
log.info("授权信息:"+authorizerInfo);

16
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java

@ -10,7 +10,7 @@ import com.epmet.dao.MiniInfoDao;
import com.epmet.dto.form.CodeAuditRecordFormDTO;
import com.epmet.dto.result.CustomerIdAndClientResultDTO;
import com.epmet.dto.result.TemplateAndAppIdResultDTO;
import com.epmet.exception.AesException;
import com.epmet.mpaes.AesException;
import com.epmet.mpaes.WXBizMsgCrypt;
import com.epmet.mpaes.WXXmlToMapUtil;
import com.epmet.service.WarrantService;
@ -26,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Map;
/**
@ -58,15 +59,14 @@ public class WarrantServiceImpl implements WarrantService {
/**
* @Description 1.保存代码审核结果 2.更新代码上传结果
* @param request
* @param appid
* @param appId
* @param response
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
@Override
public void acceptMessageAndEvent(HttpServletRequest request, String appid, HttpServletResponse response)throws IOException, DocumentException, AesException {
log.info("request:"+request);
log.info("appId:"+ appid);
public void acceptMessageAndEvent(HttpServletRequest request, String appId, HttpServletResponse response)throws IOException, DocumentException, AesException {
log.info("appId:"+ appId);
request.setCharacterEncoding(ModuleConstant.UTF8);
String msgSignature = request.getParameter(ModuleConstant.MSG_SIGNATURE);
String timeStamp = request.getParameter(ModuleConstant.TIMESTAMP);
@ -83,14 +83,16 @@ public class WarrantServiceImpl implements WarrantService {
try {
wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId);
msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData);
} catch (com.epmet.mpaes.AesException e) {
} catch (AesException e) {
e.printStackTrace();
}
log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg));
// 将xml转为map
Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg);
Map<String,Object> xml = (Map<String, Object>) result.get("xml");
Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML);
Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString());
CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class);
codeAuditRecord.setWechatCreateTime(new Date(createTime));
String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName);
String clientType = customerIdAndClientResultDTO.getClientType();

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java

@ -58,7 +58,7 @@ public interface WxMaCodeConstant {
/**
* 获取授权方的帐号基本信息
*/
String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info";
String API_GET_AUTHORIZER_INFO = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=";
/**
* 为授权的小程序帐号上传小程序代码.

18
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeAuditRecordDao.xml

@ -14,16 +14,16 @@
#{templateId},
#{clientType},
#{authAppId},
#{toUserName},
#{fromUserName},
#{ToUserName},
#{FromUserName},
#{wechatCreateTime},
#{msgType},
#{event},
IFNULL(#{succTime},NULL),
IFNULL(#{failTime},NULL),
IFNULL(#{delayTime},NULL),
IFNULL(#{reason},NULL),
IFNULL(#{screenShot},NULL),
#{MsgType},
#{Event},
IFNULL(#{SuccTime},NULL),
IFNULL(#{FailTime},NULL),
IFNULL(#{DelayTime},NULL),
IFNULL(#{Reason},NULL),
IFNULL(#{ScreenShot},NULL),
#{delFlag},
#{revision},
#{createdBy},

14
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/MiniInfoDao.xml

@ -15,14 +15,14 @@
REPLACE ( UUID(), '-', '' ),
#{customerId},
#{clientType},
#{nickName},
#{headImg},
#{serviceTypeInfo},
#{verifyTypeInfo},
#{userName},
#{principalName},
#{nick_name},
#{head_img},
#{service_type_info},
#{verify_type_info},
#{user_name},
#{principal_name},
#{signature},
#{qrcodeUrl},
#{qrcode_url},
#{delFlag},
#{revision},
#{createdBy},

14
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaInfoDao.xml

@ -15,14 +15,14 @@
REPLACE ( UUID(), '-', '' ),
#{customerId},
#{clientType},
#{nickName},
#{headImg},
#{serviceTypeInfo},
#{verifyTypeInfo},
#{userName},
#{principalName},
#{nick_name},
#{head_img},
#{service_type_info},
#{verify_type_info},
#{user_name},
#{principal_name},
#{alias},
#{qrcodeUrl},
#{qrcode_url},
#{delFlag},
#{revision},
#{createdBy},

Loading…
Cancel
Save