Browse Source

Merge remote-tracking branch 'origin/dev_thirdplatform' into dev

dev_shibei_match
zxc 5 years ago
parent
commit
4141237cf8
  1. 25
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java
  2. 23
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java
  3. 12
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java
  4. 6
      epmet-module/epmet-third/epmet-third-server/pom.xml
  5. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  6. 3
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/WarrantController.java
  7. 42
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
  8. 82
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  9. 60
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/WarrantServiceImpl.java
  10. 56
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java

25
epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java

@ -10,12 +10,17 @@ package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.QrCodeDTO;
import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.feign.fallback.OssFeignClientFallback; import com.epmet.feign.fallback.OssFeignClientFallback;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;
/** /**
* OSS * OSS
@ -23,18 +28,28 @@ import org.springframework.web.bind.annotation.PostMapping;
* @author Mark sunlightcs@gmail.c om * @author Mark sunlightcs@gmail.c om
* @since 1.1.0 * @since 1.1.0
*/ */
@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, fallback = OssFeignClientFallback.class) @FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class, fallback =
OssFeignClientFallback.class)
public interface OssFeignClient { public interface OssFeignClient {
/** /**
* 文件上传 * 文件上传
* @param dto 文件 * @param media 文件
* @return 返回路径 * @return 返回路径
*/ */
@PostMapping(value = "oss/file/uploadwximg", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "oss/file/uploadwximg", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result<UploadImgResultDTO> uploadWxImg(QrCodeDTO dto); Result<UploadImgResultDTO> uploadWxImg(@RequestPart(value = "media") MultipartFile media);
@PostMapping(value ="oss/file/uploadqrcode", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value ="oss/file/uploadqrcode", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result<UploadImgResultDTO> uploadQrCode(QrCodeDTO dto ); Result<UploadImgResultDTO> uploadQrCode(@RequestPart(value = "file") MultipartFile file);
@Configuration
class MultipartSupportConfig {
@Bean
public Encoder feignFormEncoder() {
return new SpringFormEncoder();
}
}
} }

23
epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java

@ -1,8 +1,8 @@
/** /**
* Copyright (c) 2018 人人开源 All rights reserved. * Copyright (c) 2018 人人开源 All rights reserved.
* * <p>
* https://www.renren.io * https://www.renren.io
* * <p>
* 版权所有侵权必究 * 版权所有侵权必究
*/ */
@ -11,8 +11,6 @@ package com.epmet.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.ModuleUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.QrCodeDTO;
import com.epmet.dto.UploadDTO;
import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.feign.OssFeignClient; import com.epmet.feign.OssFeignClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -27,13 +25,14 @@ import org.springframework.web.multipart.MultipartFile;
@Component @Component
public class OssFeignClientFallback implements OssFeignClient { public class OssFeignClientFallback implements OssFeignClient {
@Override @Override
public Result<UploadImgResultDTO> uploadWxImg(QrCodeDTO dto) { public Result<UploadImgResultDTO> uploadWxImg(MultipartFile media) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadWxImg", dto); return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadWxImg", media);
} }
@Override
public Result<UploadImgResultDTO> uploadQrCode(MultipartFile file) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadQrCode", file);
}
@Override
public Result<UploadImgResultDTO> uploadQrCode(QrCodeDTO dto) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadQrCode", dto);
}
} }

12
epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java

@ -18,7 +18,6 @@ import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.commons.tools.validator.group.AliyunGroup; import com.epmet.commons.tools.validator.group.AliyunGroup;
import com.epmet.commons.tools.validator.group.QcloudGroup; import com.epmet.commons.tools.validator.group.QcloudGroup;
import com.epmet.commons.tools.validator.group.QiniuGroup; import com.epmet.commons.tools.validator.group.QiniuGroup;
import com.epmet.dto.QrCodeDTO;
import com.epmet.dto.UploadDTO; import com.epmet.dto.UploadDTO;
import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.entity.OssEntity; import com.epmet.entity.OssEntity;
@ -143,16 +142,13 @@ public class OssController {
} }
@PostMapping("uploadwximg") @PostMapping("uploadwximg")
public Result<UploadImgResultDTO> uploadWxImg(QrCodeDTO dto) { public Result<UploadImgResultDTO> uploadWxImg(@RequestPart("media") MultipartFile media) {
return ossService.uploadImg(dto.getMedia()); return ossService.uploadImg(media);
} }
@PostMapping("uploadqrcode") @PostMapping("uploadqrcode")
public Result<UploadImgResultDTO> uploadQrCode(QrCodeDTO dto) { public Result<UploadImgResultDTO> uploadQrCode(@RequestPart(value = "file") MultipartFile file) {
String url = OssFactory.build().uploadSuffix(dto.getQrCode(), "jpg"); return ossService.uploadImg(file);
UploadImgResultDTO result = new UploadImgResultDTO();
result.setUrl(url);
return new Result<UploadImgResultDTO>().ok(result);
} }
/** /**
* 上传客户logo(考虑到以后可能会针对不同的业务有不同的限制条件这里不再使用通用的接口 * 上传客户logo(考虑到以后可能会针对不同的业务有不同的限制条件这里不再使用通用的接口

6
epmet-module/epmet-third/epmet-third-server/pom.xml

@ -141,6 +141,12 @@
<version>2.0.0</version> <version>2.0.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.1.12.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

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

@ -75,6 +75,9 @@ public interface ModuleConstant {
//代码审核结果推送 如下 //代码审核结果推送 如下
String EVENT = "Event"; String EVENT = "Event";
String MSG_TYPE = "MsgType";
String EVENT_LOW = "event";
String TEXT = "text";
String WEAPP_AUDIT_SUCCESS = "weapp_audit_success"; //审核通过 String WEAPP_AUDIT_SUCCESS = "weapp_audit_success"; //审核通过
String WEAPP_AUDIT_FAIL = "weapp_audit_fail"; //审核不通过 String WEAPP_AUDIT_FAIL = "weapp_audit_fail"; //审核不通过
String WEAPP_AUDIT_DELAY = "weapp_audit_delay"; //审核延后 String WEAPP_AUDIT_DELAY = "weapp_audit_delay"; //审核延后

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

@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -25,7 +26,7 @@ public class WarrantController {
@Autowired @Autowired
private WarrantService warrantService; private WarrantService warrantService;
@RequestMapping(value ="/{APPID}/callback") @PostMapping(value ="/{APPID}/callback")
public String acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid, public String acceptMessageAndEvent(HttpServletRequest request, @PathVariable("APPID") String appid,
HttpServletResponse response)throws IOException, DocumentException, AesException { HttpServletResponse response)throws IOException, DocumentException, AesException {
return warrantService.acceptMessageAndEvent(request, appid, response); return warrantService.acceptMessageAndEvent(request, appid, response);

42
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java

@ -1,5 +1,6 @@
package com.epmet.service.impl; package com.epmet.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
@ -16,22 +17,20 @@ import com.epmet.dto.result.*;
import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.feign.OssFeignClient; import com.epmet.feign.OssFeignClient;
import com.epmet.service.*; import com.epmet.service.*;
import com.epmet.wxapi.param.WxMaCodeAuditStatusReq; import com.epmet.wxapi.param.*;
import com.epmet.wxapi.param.WxMaCodeCommitReq;
import com.epmet.wxapi.param.WxMaCodeSubmitAuditRequest;
import com.epmet.wxapi.param.WxMaNewsReq;
import com.epmet.wxapi.result.*; import com.epmet.wxapi.result.*;
import com.epmet.wxapi.service.WxMaCodeService; import com.epmet.wxapi.service.WxMaCodeService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -68,8 +67,6 @@ public class CodeServiceImpl implements CodeService {
private OssFeignClient ossFeignClient; private OssFeignClient ossFeignClient;
@Autowired @Autowired
private PaCustomerService paCustomerService; private PaCustomerService paCustomerService;
@Autowired
private WxMaCodeService wxsMaCodeService;
@Override @Override
public List<TemplateListResultDTO> templateList() { public List<TemplateListResultDTO> templateList() {
@ -104,6 +101,15 @@ public class CodeServiceImpl implements CodeService {
return codeExtDTO.getExtJson(); return codeExtDTO.getExtJson();
} }
public static void main(String[] args) {
String json = "{\"extEnable\":true,\"extAppid\":\"wx2679392c4cc2af22\",\"directCommit\":false,\"ext\":{\"extAppid\":\"wx2679392c4cc2af22\",\"footbar\":{\"work\":{\"name\":\"工作\",\"pageTile\":\"工作\"},\"org\":{\"name\":\"组织\",\"pageTile\":\"组织\"},\"data\":{\"name\":\"数据\",\"pageTile\":\"数据\"},\"find\":{\"name\":\"更多\",\"pageTile\":\"更多\"}}}}";
WxExtJson wxExtJson = JSONObject.parseObject(json, WxExtJson.class);
wxExtJson.setExtAppid("123456");
wxExtJson.getExt().setExtAppid("123456");
String extJson = JSON.toJSONString(wxExtJson);
System.out.println(extJson);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void upload(CodeUploadFormDTO formDTO) { public void upload(CodeUploadFormDTO formDTO) {
@ -120,20 +126,24 @@ public class CodeServiceImpl implements CodeService {
throw new RenException("第三方配置不是有效的Json"); throw new RenException("第三方配置不是有效的Json");
} }
WxExtJson wxExtJson = JSONObject.parseObject(formDTO.getExtJson(), WxExtJson.class);
wxExtJson.setExtAppid(authInfo.getAuthorizerAppid());
wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid());
String extJson = JSON.toJSONString(wxExtJson);
CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
if (null == codeExtDTO) { if (null == codeExtDTO) {
codeExtDTO = new CodeExtDTO(); codeExtDTO = new CodeExtDTO();
codeExtDTO.setCustomerId(formDTO.getCustomerId()); codeExtDTO.setCustomerId(formDTO.getCustomerId());
codeExtDTO.setClientType(formDTO.getClientType()); codeExtDTO.setClientType(formDTO.getClientType());
codeExtDTO.setAppId(authInfo.getAuthorizerAppid()); codeExtDTO.setAppId(authInfo.getAuthorizerAppid());
codeExtDTO.setExtJson(formDTO.getExtJson()); codeExtDTO.setExtJson(extJson);
codeExtService.save(codeExtDTO); codeExtService.save(codeExtDTO);
} }
codeExtDTO.setExtJson(formDTO.getExtJson()); codeExtDTO.setExtJson(extJson);
codeExtService.update(codeExtDTO); codeExtService.update(codeExtDTO);
WxMaCodeCommitReq request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeCommitReq.class); WxMaCodeCommitReq request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeCommitReq.class);
request.setExtJson(formDTO.getExtJson()); request.setExtJson(extJson);
//调用微信API上传代码 //调用微信API上传代码
WxResult wxResult = wxMaCodeService.commit(authInfo.getAuthorizerAccessToken(), request); WxResult wxResult = wxMaCodeService.commit(authInfo.getAuthorizerAccessToken(), request);
//上传失败,抛出异常 //上传失败,抛出异常
@ -151,7 +161,7 @@ public class CodeServiceImpl implements CodeService {
//将上传信息存入表中 //将上传信息存入表中
CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class); CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class);
codeCustomerDTO.setCustomerName(paCustomerDTO.getCustomerName()); codeCustomerDTO.setCustomerName(paCustomerDTO.getCustomerName());
codeCustomerDTO.setExtJson(formDTO.getExtJson()); codeCustomerDTO.setExtJson(extJson);
codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid()); codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid());
codeCustomerDTO.setStatus(CodeConstant.UNAUDITED); codeCustomerDTO.setStatus(CodeConstant.UNAUDITED);
codeCustomerService.save(codeCustomerDTO); codeCustomerService.save(codeCustomerDTO);
@ -374,9 +384,9 @@ public class CodeServiceImpl implements CodeService {
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType()); AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType());
//调用微信API获取获取体验版二维码 //调用微信API获取获取体验版二维码
WxResult<byte[]> wxResult = wxMaCodeService.getQrCode(authInfo.getAuthorizerAccessToken(), formDTO.getPath()); WxResult<byte[]> wxResult = wxMaCodeService.getQrCode(authInfo.getAuthorizerAccessToken(), formDTO.getPath());
QrCodeDTO qrCodeDTO = new QrCodeDTO(); MultipartFile file = null;
qrCodeDTO.setQrCode(wxResult.getData()); file = new MockMultipartFile("file", "QRCode.jpg", "image/jpeg", wxResult.getData());
Result<UploadImgResultDTO> uploadResult = ossFeignClient.uploadQrCode(qrCodeDTO); Result<UploadImgResultDTO> uploadResult = ossFeignClient.uploadQrCode(file);
codeCustomerDTO.setQrCode(uploadResult.getData().getUrl()); codeCustomerDTO.setQrCode(uploadResult.getData().getUrl());
codeCustomerService.update(codeCustomerDTO); codeCustomerService.update(codeCustomerDTO);
result.setQrcode(uploadResult.getData().getUrl()); result.setQrcode(uploadResult.getData().getUrl());
@ -399,9 +409,7 @@ public class CodeServiceImpl implements CodeService {
@Override @Override
public String mediaUpload(MediaUploadFormDTO formDTO) { public String mediaUpload(MediaUploadFormDTO formDTO) {
try { try {
QrCodeDTO dto = new QrCodeDTO(); Result<UploadImgResultDTO> uploadWxImg = ossFeignClient.uploadWxImg(formDTO.getMedia());
dto.setMedia(formDTO.getMedia());
Result<UploadImgResultDTO> uploadWxImg = ossFeignClient.uploadWxImg(dto);
File file = new File(uploadWxImg.getData().getUrl()); File file = new File(uploadWxImg.getData().getUrl());
//获取上传代码信息 //获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId()); CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());

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

@ -201,24 +201,26 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket);
String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData();
Map hashMap = JSON.parseObject(post, Map.class); Map hashMap = JSON.parseObject(post, Map.class);
String componentAccessToken = hashMap.get(COMPONENT_ACCESS_TOKEN).toString(); if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) {
Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); String componentAccessToken = hashMap.get(COMPONENT_ACCESS_TOKEN).toString();
Date expiresInTime = this.countExpirationTime(expiresIn.toString()); Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN);
if (StringUtils.isNotEmpty(componentAccessToken)) { Date expiresInTime = this.countExpirationTime(expiresIn.toString());
//令牌信息存DB if (StringUtils.isNotEmpty(componentAccessToken)) {
ComponentAccessTokenFormDTO formDTO = new ComponentAccessTokenFormDTO(); //令牌信息存DB
formDTO.setComponentAccessToken(componentAccessToken); ComponentAccessTokenFormDTO formDTO = new ComponentAccessTokenFormDTO();
formDTO.setExpiresInTime(expiresInTime); formDTO.setComponentAccessToken(componentAccessToken);
//先逻辑删,在插入 formDTO.setExpiresInTime(expiresInTime);
log.info(ThirdRunTimeInfoConstant.START_DELETE_COMPONENT_ACCESS_TOKEN); //先逻辑删,在插入
componentAccessTokenDao.deleteOldComponentAccessToken(); log.info(ThirdRunTimeInfoConstant.START_DELETE_COMPONENT_ACCESS_TOKEN);
componentAccessTokenDao.insertComponentAccessToken(formDTO); componentAccessTokenDao.deleteOldComponentAccessToken();
//存缓存 componentAccessTokenDao.insertComponentAccessToken(formDTO);
redisThird.setComponentAccessToken(componentAccessToken); //存缓存
} else { redisThird.setComponentAccessToken(componentAccessToken);
throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN); } else {
throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN);
}
log.info(ThirdRunTimeInfoConstant.SUCCESS_ACCESS_TOKEN);
} }
log.info(ThirdRunTimeInfoConstant.SUCCESS_ACCESS_TOKEN);
} }
} }
@ -232,31 +234,27 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
public String preAuthCode() { public String preAuthCode() {
log.info(START_GET_PRE_AUTH_CODE); log.info(START_GET_PRE_AUTH_CODE);
String preAuthCode = ""; String preAuthCode = "";
try { String accessToken = redisThird.getComponentAccessToken();
String accessToken = redisThird.getComponentAccessToken(); JSONObject jsonObject = new JSONObject();
JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId);
jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData();
String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); log.info(String.format(POST_RESULT,post));
log.info(String.format(POST_RESULT,post)); Map hashMap = JSON.parseObject(post, Map.class);
Map hashMap = JSON.parseObject(post, Map.class); preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString();
preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN);
Integer expiresIn = (Integer) hashMap.get(ModuleConstant.EXPIRES_IN); Date expiresInTime = this.countExpirationTime(expiresIn.toString());
Date expiresInTime = this.countExpirationTime(expiresIn.toString()); if (StringUtils.isNotEmpty(preAuthCode)) {
if (StringUtils.isNotEmpty(preAuthCode)) { //预授权码 存DB
//预授权码 存DB PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO();
PreAuthTokenFormDTO formDTO = new PreAuthTokenFormDTO(); formDTO.setPreAuthToken(preAuthCode);
formDTO.setPreAuthToken(preAuthCode); formDTO.setExpiresInTime(expiresInTime);
formDTO.setExpiresInTime(expiresInTime); //先逻辑删除,在插入DB
//先逻辑删除,在插入DB preAuthTokenDao.updateOldPreAuthCode();
preAuthTokenDao.updateOldPreAuthCode(); preAuthTokenDao.insertPreAuthToken(formDTO);
preAuthTokenDao.insertPreAuthToken(formDTO); //预授权码 放入缓存
//预授权码 放入缓存 redisThird.setPreAuthCode(preAuthCode);
redisThird.setPreAuthCode(preAuthCode); } else {
} else { throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE);
throw new RuntimeException(FAILURE_GET_PRE_AUTH_CODE);
}
} catch (Exception e) {
e.printStackTrace();
} }
log.info(END_GET_PRE_AUTH_CODE); log.info(END_GET_PRE_AUTH_CODE);
return preAuthCode; return preAuthCode;

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

@ -90,35 +90,39 @@ public class WarrantServiceImpl implements WarrantService {
// 将xml转为map // 将xml转为map
Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg); Map<String, Object> result = WXXmlToMapUtil.multilayerXmlToMap(msg);
Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML); Map<String,Object> xml = (Map<String, Object>) result.get(ModuleConstant.XML);
Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString()); if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.EVENT_LOW)) {
CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class); Long createTime = Long.valueOf(xml.get(ModuleConstant.CREATE_TIME).toString());
codeAuditRecord.setWechatCreateTime(new Date(createTime)); CodeAuditRecordFormDTO codeAuditRecord = componentVerifyTicketService.mapToEntity(xml, CodeAuditRecordFormDTO.class);
String toUserName = codeAuditRecord.getToUserName();//小程序原始ID codeAuditRecord.setWechatCreateTime(new Date(createTime));
CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName); String toUserName = codeAuditRecord.getToUserName();//小程序原始ID
String clientType = customerIdAndClientResultDTO.getClientType(); CustomerIdAndClientResultDTO customerIdAndClientResultDTO = miniInfoDao.selectCustomerIdAndClientByToUserName(toUserName);
String customerId = customerIdAndClientResultDTO.getCustomerId(); String clientType = customerIdAndClientResultDTO.getClientType();
TemplateAndAppIdResultDTO templateAndAppId = codeCustomerDao.selectTemplateAndAppId(customerId, clientType); String customerId = customerIdAndClientResultDTO.getCustomerId();
String authAppId = templateAndAppId.getAuthAppId(); TemplateAndAppIdResultDTO templateAndAppId = codeCustomerDao.selectTemplateAndAppId(customerId, clientType);
String templateId = templateAndAppId.getTemplateId(); String authAppId = templateAndAppId.getAuthAppId();
codeAuditRecord.setClientType(clientType); String templateId = templateAndAppId.getTemplateId();
codeAuditRecord.setCustomerId(customerId); codeAuditRecord.setClientType(clientType);
codeAuditRecord.setAuthAppId(authAppId); codeAuditRecord.setCustomerId(customerId);
codeAuditRecord.setTemplateId(templateId); codeAuditRecord.setAuthAppId(authAppId);
//插入 代码审核 记录 codeAuditRecord.setTemplateId(templateId);
codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord); //插入 代码审核 记录
// 修改 code_audit_result 中的代码审核结果 codeAuditRecordDao.insertCodeAuditRecord(codeAuditRecord);
String event = codeAuditRecord.getEvent(); // 修改 code_audit_result 中的代码审核结果
String codeResult = null; String event = codeAuditRecord.getEvent();
switch (event){ String codeResult = null;
case ModuleConstant.WEAPP_AUDIT_SUCCESS: switch (event) {
codeResult = ModuleConstant.AUDIT_SUCCESS; case ModuleConstant.WEAPP_AUDIT_SUCCESS:
case ModuleConstant.WEAPP_AUDIT_FAIL: codeResult = ModuleConstant.AUDIT_SUCCESS;
codeResult = ModuleConstant.AUDIT_FAILED; case ModuleConstant.WEAPP_AUDIT_FAIL:
case ModuleConstant.WEAPP_AUDIT_DELAY: codeResult = ModuleConstant.AUDIT_FAILED;
codeResult = ModuleConstant.DELAY; case ModuleConstant.WEAPP_AUDIT_DELAY:
codeResult = ModuleConstant.DELAY;
}
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord);
codeAuditResultDao.updateAuditResult(customerId, codeCustomerId, codeResult);
}else if (xml.get(ModuleConstant.MSG_TYPE).equals(ModuleConstant.TEXT)){
} }
String codeCustomerId = codeCustomerDao.selectCodeCustomerId(codeAuditRecord);
codeAuditResultDao.updateAuditResult(customerId,codeCustomerId,codeResult);
return ModuleConstant.SUCCESS; return ModuleConstant.SUCCESS;
} }
} }

56
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java

@ -1,5 +1,6 @@
package com.epmet.wxapi.param; package com.epmet.wxapi.param;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -15,50 +16,101 @@ import java.io.Serializable;
public class WxExtJson implements Serializable { public class WxExtJson implements Serializable {
private static final long serialVersionUID = -559311391779774945L; private static final long serialVersionUID = -559311391779774945L;
@JSONField(ordinal = 1)
private boolean extEnable; private boolean extEnable;
@JSONField(ordinal = 2)
private String extAppid; private String extAppid;
@JSONField(ordinal = 3)
private boolean directCommit; private boolean directCommit;
@JSONField(ordinal = 4)
private ExtBean ext; private ExtBean ext;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
private static class ExtBean { public static class ExtBean {
@JSONField(ordinal = 1)
private String extAppid; private String extAppid;
@JSONField(ordinal = 2)
private FootbarBean footbar; private FootbarBean footbar;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
private static class FootbarBean { private static class FootbarBean {
@JSONField(ordinal = 1)
private WorkBean work; private WorkBean work;
@JSONField(ordinal = 2)
private OrgBean org; private OrgBean org;
@JSONField(ordinal = 3)
private DataBean data; private DataBean data;
@JSONField(ordinal = 4)
private FindBean find; private FindBean find;
@JSONField(ordinal = 5)
private GardenBean garden;
@JSONField(ordinal = 6)
private IssueBean issue;
@JSONField(ordinal = 7)
private GroupBean group;
@NoArgsConstructor @NoArgsConstructor
@Data @Data
private static class WorkBean { private static class WorkBean {
@JSONField(ordinal = 1)
private String name; private String name;
@JSONField(ordinal = 2)
private String pageTile; private String pageTile;
} }
@NoArgsConstructor @NoArgsConstructor
@Data @Data
private static class OrgBean { private static class OrgBean {
@JSONField(ordinal = 1)
private String name; private String name;
@JSONField(ordinal = 2)
private String pageTile; private String pageTile;
} }
@NoArgsConstructor @NoArgsConstructor
@Data @Data
private static class DataBean { private static class DataBean {
@JSONField(ordinal = 1)
private String name; private String name;
@JSONField(ordinal = 2)
private String pageTile; private String pageTile;
} }
@NoArgsConstructor @NoArgsConstructor
@Data @Data
private static class FindBean { private static class FindBean {
@JSONField(ordinal = 1)
private String name;
@JSONField(ordinal = 2)
private String pageTile;
}
@NoArgsConstructor
@Data
private static class GardenBean {
@JSONField(ordinal = 1)
private String name;
@JSONField(ordinal = 2)
private String pageTile;
}
@NoArgsConstructor
@Data
private static class IssueBean {
@JSONField(ordinal = 1)
private String name;
@JSONField(ordinal = 2)
private String pageTile;
}
@NoArgsConstructor
@Data
private static class GroupBean {
@JSONField(ordinal = 1)
private String name; private String name;
@JSONField(ordinal = 2)
private String pageTile; private String pageTile;
} }
} }

Loading…
Cancel
Save