Browse Source

Merge branch 'dev_thirdplatform' of http://git.elinkit.com.cn:7070/r/epmet-cloud into dev_thirdplatform

dev_shibei_match
sunyuchao 5 years ago
parent
commit
ce8299bae7
  1. 23
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java
  2. 3
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java
  3. 2
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java
  4. 5
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java
  5. 24
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java
  6. 4
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java
  7. 6
      epmet-module/epmet-third/epmet-third-server/pom.xml
  8. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ThirdRedisKeyConstant.java
  9. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java
  10. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java
  11. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java
  12. 2
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java
  13. 99
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java
  14. 84
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java
  15. 7
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxMaCodeConstant.java
  16. 101
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java
  17. 23
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java
  18. 35
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java
  19. 15
      epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml
  20. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
  21. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml
  22. 4
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml
  23. 6
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml
  24. 2
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml
  25. 4
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml
  26. 4
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml
  27. 2
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

23
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java

@ -20,7 +20,9 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.HttpMultipartMode;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
@ -36,6 +38,8 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -139,11 +143,20 @@ public class HttpClientManager {
try {
HttpPost httppost = new HttpPost(url);
httppost.setConfig(requestConfig);
httppost.addHeader("Content-Type", "application/json; charset=utf-8");
FileBody fileBody = new FileBody(file);
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("media", fileBody).build();
httppost.setEntity(reqEntity);
String boundaryStr = "------------" + System.currentTimeMillis();
httppost.addHeader("Connection", "keep-alive");
httppost.addHeader("Accept", "*/*");
httppost.addHeader("Content-Type", "multipart/form-data;boundary=" + boundaryStr);
httppost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) ");
MultipartEntityBuilder meb = MultipartEntityBuilder.create();
meb.setBoundary(boundaryStr).setCharset(StandardCharsets.UTF_8).setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
meb.addBinaryBody("media", file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
HttpEntity entity = meb.build();
httppost.setEntity(entity);
// FileBody fileBody = new FileBody(file);
// HttpEntity reqEntity = MultipartEntityBuilder.create()
// .addPart("media", fileBody).build();
// httppost.setEntity(reqEntity);
return execute(httppost);
} catch (Exception e) {
log.error("send exception", e);

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

@ -8,6 +8,7 @@
package com.epmet.feign;
import com.epmet.commons.tools.constant.ServiceConstant;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import com.epmet.commons.tools.utils.Result;
@ -25,7 +26,7 @@ import org.springframework.web.multipart.MultipartFile;
* @author Mark sunlightcs@gmail.c om
* @since 1.1.0
*/
@FeignClient(name = "renren-oss-server", configuration = OssFeignClient.MultipartSupportConfig.class)
@FeignClient(name = ServiceConstant.EPMET_OSS_SERVER, configuration = OssFeignClient.MultipartSupportConfig.class)
public interface OssFeignClient {
/**
* 文件上传

2
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/CodeOperationHistoryDTO.java

@ -61,7 +61,7 @@ public class CodeOperationHistoryDTO implements Serializable {
/**
* 描述
*/
private String describe;
private String description;
/**
* 乐观锁

5
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AuthorizerAccessTokenFormDTO.java

@ -34,6 +34,11 @@ public class AuthorizerAccessTokenFormDTO implements Serializable {
*/
private String authAppid;
/**
* 客户端类型resi居民端work工作端
*/
private String clientType;
/**
* 客户ID
*/

24
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubmitAuditFormDTO.java

@ -43,84 +43,100 @@ public class SubmitAuditFormDTO implements Serializable {
/**
* 用户生成内容场景UGC信息安全声明
*/
private List<UgcDeclareBean> ugcDeclare;
private UgcDeclareBean ugcDeclare;
@NoArgsConstructor
@Data
private static class ItemListBean {
public static class ItemListBean {
/**
* 小程序的页面可通过获取小程序的页面列表接口获得
*/
@SerializedName("address")
private String address;
/**
* 小程序的标签用空格分隔标签至多 10 标签长度至多 20
*/
@SerializedName("tag")
private String tag;
/**
* 一级类目名称
*/
@SerializedName("first_class")
private String firstClass;
/**
* 二级类目名称
*/
@SerializedName("second_class")
private String secondClass;
/**
* 三级类目名称
*/
@SerializedName("third_class")
private String thirdClass;
/**
* 一级类目的 ID
*/
@SerializedName("first_id")
private String firstId;
/**
* 二级类目的 ID
*/
@SerializedName("second_id")
private String secondId;
/**
* 三级类目的 ID
*/
@SerializedName("third_id")
private String thirdId;
/**
* 小程序页面的标题,标题长度至多 32
*/
@SerializedName("title")
private String title;
}
@NoArgsConstructor
@Data
private static class PreviewInfoBean {
public static class PreviewInfoBean {
/**
* 录屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("Video_id_list")
private List<String> videoIdList;
/**
* 截屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("pic_id_list")
private List<String> picIdList;
}
@NoArgsConstructor
@Data
private static class UgcDeclareBean {
public static class UgcDeclareBean {
/**
* UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段
*/
@SerializedName("scene")
private List<Integer> scene;
/**
* 当scene选其他时的说明,不超时256字
*/
@SerializedName("other_scene_desc")
private String otherSceneDesc;
/**
* 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关
*/
@SerializedName("method")
private List<Integer> method;
/**
* 是否有审核团队, 0.,1.,默认0
*/
@SerializedName("has_audit_team")
private Integer hasAuditTeam;
/**
* 说明当前对UGC内容的审核机制,不超过256字
*/
@SerializedName("audit_desc")
private String auditDesc;
}
}

4
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/UploadListFormDTO.java

@ -38,9 +38,9 @@ public class UploadListFormDTO implements Serializable {
/**
* 页数
*/
private Integer page;
private Integer pageNo;
/**
* 页面条数
*/
private Integer limit;
private Integer pageSize;
}

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

@ -135,6 +135,12 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

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

@ -44,7 +44,7 @@ public interface ThirdRedisKeyConstant {
/**
* authorization_info 授权信息
*/
String AUTH_INFO_REDIS_KEY = "epmet:wechartthird:authinfo";
String AUTH_INFO_REDIS_KEY = "epmet:wechartthird:authinfo:";
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/CodeController.java

@ -49,7 +49,7 @@ public class CodeController {
* @date 2020/7/17 16:22
*/
@PostMapping("getextjson")
public Result<String> getExtJson(CodeUploadFormDTO formDTO) {
public Result<String> getExtJson(@RequestBody CodeUploadFormDTO formDTO) {
String extJson = codeService.getExtJson(formDTO);
return new Result<String>().ok(extJson);
}
@ -175,7 +175,7 @@ public class CodeController {
* @date 2020/7/17 11:20
*/
@PostMapping("mediaupload")
public Result<String> mediaUpload(@RequestBody MediaUploadFormDTO formDTO) {
public Result<String> mediaUpload(MediaUploadFormDTO formDTO) {
String result = codeService.mediaUpload(formDTO);
return new Result<String>().ok(result);
}

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/CustomerMpDao.java

@ -58,7 +58,7 @@ public interface CustomerMpDao extends BaseDao<CustomerMpEntity> {
* @param customerId
* @author zxc
*/
Integer selectAuthCount(@Param("customerId")String customerId);
List<String> selectAuthCount(@Param("customerId")String customerId);
/**
* @Description 回填customer_mp的appId

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/CodeOperationHistoryEntity.java

@ -61,6 +61,6 @@ public class CodeOperationHistoryEntity extends BaseEpmetEntity {
/**
* 描述
*/
private String describe;
private String description;
}

2
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeCustomerServiceImpl.java

@ -107,7 +107,7 @@ public class CodeCustomerServiceImpl extends BaseServiceImpl<CodeCustomerDao, Co
@Override
public PageData getCodeList(UploadListFormDTO formDTO) {
PageHelper.startPage(formDTO.getPage(), formDTO.getLimit());
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize());
List<UploadListResultDTO> list = baseDao.selectCodeList(formDTO);
PageInfo<UploadListResultDTO> pageInfo = new PageInfo<>(list);
return new PageData<>(list, pageInfo.getTotal());

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

@ -13,8 +13,12 @@ import com.epmet.dao.AuthorizationInfoDao;
import com.epmet.dao.ComponentAccessTokenDao;
import com.epmet.dto.*;
import com.epmet.dto.form.*;
import com.epmet.dto.result.*;
import com.epmet.dto.result.CodeHistoryResultDTO;
import com.epmet.dto.result.QrCodeResultDTO;
import com.epmet.dto.result.ReasonResultDTO;
import com.epmet.dto.result.TemplateListResultDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.service.*;
import com.epmet.wxapi.param.WxMaCodeAuditStatusReq;
import com.epmet.wxapi.param.WxMaCodeCommitReq;
@ -24,8 +28,6 @@ import com.epmet.wxapi.result.*;
import com.epmet.wxapi.service.WxMaCodeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -63,6 +65,8 @@ public class CodeServiceImpl implements CodeService {
private CodeMediaService codeMediaService;
@Autowired
private CodeExtService codeExtService;
@Autowired
private OssFeignClient ossFeignClient;
@Override
public List<TemplateListResultDTO> templateList() {
@ -101,7 +105,7 @@ public class CodeServiceImpl implements CodeService {
@Transactional(rollbackFor = Exception.class)
public void upload(CodeUploadFormDTO formDTO) {
//是否授权
if (customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) {
if (!customerMpService.getAuthFlag(formDTO.getCustomerId(), formDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -148,6 +152,7 @@ public class CodeServiceImpl implements CodeService {
CodeCustomerDTO codeCustomerDTO = ConvertUtils.sourceToTarget(formDTO, CodeCustomerDTO.class);
codeCustomerDTO.setCustomerName(customerInfo.getData().getCustomerName());
codeCustomerDTO.setExtJson(formDTO.getExtJson());
codeCustomerDTO.setAppId(authInfo.getAuthorizerAppid());
codeCustomerDTO.setStatus(CodeConstant.UNAUDITED);
codeCustomerService.save(codeCustomerDTO);
@ -156,39 +161,40 @@ public class CodeServiceImpl implements CodeService {
@Override
public PageData uploadList(UploadListFormDTO formDTO) {
//获取小程序调用令牌
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), formDTO.getClientType());
if (null == authInfo) {
throw new RenException("未授权");
}
List<CodeCustomerDTO> auditingList = codeCustomerService.getAuditingCodeList();
auditingList.forEach(code -> {
//获取审核结果信息
CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId());
//调用微信API获取最新审核状态
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq();
request.setAuditId(auditResult.getAuditId());
WxResult<WxMaAuditStatusResult> wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request);
if (wxAuditResult.success()) {
WxMaAuditStatusResult result = wxAuditResult.getData();
if (result.getStatus() == NumConstant.ZERO) {
code.setStatus(CodeConstant.AUDIT_SUCCESS);
auditResult.setResult(CodeConstant.AUDIT_SUCCESS);
codeOperationHistoryService.updateDescribe(code.getId(), "审核成功");
} else if (result.getStatus() == NumConstant.ONE) {
code.setStatus(CodeConstant.AUDIT_FAILED);
auditResult.setResult(CodeConstant.AUDIT_FAILED);
auditResult.setReason(result.getReason());
codeOperationHistoryService.updateDescribe(code.getId(), result.getReason());
} else if (result.getStatus() == NumConstant.FOUR) {
code.setStatus(CodeConstant.DELAY);
auditResult.setResult(CodeConstant.DELAY);
codeOperationHistoryService.updateDescribe(code.getId(), "审核延后");
if (null != auditingList && auditingList.size() > NumConstant.ZERO) {
auditingList.forEach(code -> {
//获取小程序调用令牌
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(code.getCustomerId(), code.getClientType());
//获取审核结果信息
CodeAuditResultDTO auditResult = codeAuditResultService.getAuditResultByCodeId(code.getId());
//调用微信API获取最新审核状态
WxMaCodeAuditStatusReq request = new WxMaCodeAuditStatusReq();
request.setAuditId(auditResult.getAuditId());
WxResult<WxMaAuditStatusResult> wxAuditResult = wxMaCodeService.getAuditStatus(authInfo.getAuthorizerAccessToken(), request);
if (wxAuditResult.success()) {
WxMaAuditStatusResult result = wxAuditResult.getData();
if (result.getStatus() == NumConstant.ZERO) {
code.setStatus(CodeConstant.AUDIT_SUCCESS);
auditResult.setResult(CodeConstant.AUDIT_SUCCESS);
codeOperationHistoryService.updateDescribe(code.getId(), "审核成功");
} else if (result.getStatus() == NumConstant.ONE) {
code.setStatus(CodeConstant.AUDIT_FAILED);
auditResult.setResult(CodeConstant.AUDIT_FAILED);
auditResult.setReason(result.getReason());
auditResult.setScreenShot(result.getScreenshot());
codeOperationHistoryService.updateDescribe(code.getId(), result.getReason());
} else if (result.getStatus() == NumConstant.FOUR) {
code.setStatus(CodeConstant.DELAY);
auditResult.setResult(CodeConstant.DELAY);
auditResult.setReason(result.getReason());
codeOperationHistoryService.updateDescribe(code.getId(), "审核延后");
}
codeCustomerService.update(code);
codeAuditResultService.update(auditResult);
}
codeCustomerService.update(code);
codeAuditResultService.update(auditResult);
}
});
});
}
return codeCustomerService.getCodeList(formDTO);
}
@ -197,7 +203,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -206,7 +212,13 @@ public class CodeServiceImpl implements CodeService {
throw new RenException("未授权");
}
//调用微信API上提交审核
WxMaCodeSubmitAuditRequest request = ConvertUtils.sourceToTarget(formDTO, WxMaCodeSubmitAuditRequest.class);
WxMaCodeSubmitAuditRequest request = new WxMaCodeSubmitAuditRequest();
request.setVersionDesc(formDTO.getVersionDesc());
request.setFeedbackInfo(formDTO.getFeedbackInfo());
request.setFeedbackStuff(formDTO.getFeedbackStuff());
request.setItemList(formDTO.getItemList());
request.setPreviewInfo(formDTO.getPreviewInfo());
request.setUgcDeclare(formDTO.getUgcDeclare());
WxResult<String> wxResult = wxMaCodeService.submitAudit(authInfo.getAuthorizerAccessToken(), request);
if (!wxResult.success()) {
saveOperation(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getId(), codeCustomerDTO.getUserVersion(), CodeConstant.OPER_SUBMIT,
@ -232,7 +244,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取审核结果信息
@ -277,7 +289,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -308,7 +320,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType());
@ -343,7 +355,7 @@ public class CodeServiceImpl implements CodeService {
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
//是否授权
if (customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
if (!customerMpService.getAuthFlag(codeCustomerDTO.getCustomerId(), codeCustomerDTO.getClientType())) {
throw new RenException("未授权");
}
//获取小程序调用令牌
@ -370,6 +382,7 @@ public class CodeServiceImpl implements CodeService {
@Override
public String mediaUpload(MediaUploadFormDTO formDTO) {
try {
// Result<UploadDTO> uploadDTOResult = ossFeignClient.upload(formDTO.getMedia());
File file = MultipartFileToFileUtils.multipartFileToFile(formDTO.getMedia());
//获取上传代码信息
CodeCustomerDTO codeCustomerDTO = codeCustomerService.get(formDTO.getCodeId());
@ -383,7 +396,7 @@ public class CodeServiceImpl implements CodeService {
CodeMediaDTO codeMediaDTO = new CodeMediaDTO();
codeMediaDTO.setCodeId(formDTO.getCodeId());
codeMediaDTO.setMediaId(wxResult.getData().getMediaId());
codeMediaDTO.setMediaName(formDTO.getMedia().getName());
codeMediaDTO.setMediaName(formDTO.getMedia().getOriginalFilename());
codeMediaDTO.setMediaType(wxResult.getData().getType());
codeMediaService.save(codeMediaDTO);
return wxResult.getData().getMediaId();
@ -399,7 +412,7 @@ public class CodeServiceImpl implements CodeService {
operationDTO.setCodeId(codeId);
operationDTO.setVersion(version);
operationDTO.setOperation(operation);
operationDTO.setDescribe(describe);
operationDTO.setDescription(describe);
codeOperationHistoryService.save(operationDTO);
}

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

@ -143,7 +143,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
AuthCodeResultDTO authCodeResultDTO = authorizationInfoDao.selectCustomerIdByAuthAppId(authAppId);
String clientType = authCodeResultDTO.getClientType();
String customerId = authCodeResultDTO.getCustomerId();
this.updateCustomerMpAppIdAndCreateOpenPlatform(customerId,authAppId,clientType);
this.createAndBindOpenAccount(customerId,authAppId,clientType);
this.updateCustomerMpAppId(customerId,authAppId,clientType);
authCodeDao.updateAppId(customerId,clientType,authAppId);
this.saveAuthAccountInfo(customerId,authAppId,clientType);
break;
@ -349,8 +350,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
formDTO.setExpiresInTime(expiresInTime);
formDTO.setCustomerId(customerId);
formDTO.setAuthAppid(authAppId);
formDTO.setClientType(clientType);
//先逻辑删除,在插入
authorizationInfoDao.updateOldAuthorizerAccessToken(willOverDueDTO.getCustomerId(),clientType);
authorizationInfoDao.updateOldAuthorizerAccessToken(customerId,clientType);
authorizationInfoDao.insertAuthorizerAccessToken(formDTO);
//缓存 refreshAuthorizerAccessToken
@ -495,7 +497,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
* @author zxc
*/
@Transactional(rollbackFor = Exception.class)
public void updateCustomerMpAppIdAndCreateOpenPlatform(String customerId,String authAppId,String clientType){
public void updateCustomerMpAppId(String customerId,String authAppId,String clientType){
log.info("==========回填customer_mp开始==========");
AuthCodeFormDTO formDTO = new AuthCodeFormDTO();
formDTO.setClientType(clientType);
@ -506,6 +508,82 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe
log.info("==========回填customer_mp结束==========");
}
public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){
log.info("开始创建开放平台账号并绑定");
List<String> authCount = customerMpDao.selectAuthCount(customerId);
String openPlatformId = null;
if (authCount.size()>0){
openPlatformId = openPlatformAccountDao.selectOpenAppIdByCustomerId(customerId);
}
Map<String, Object> authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType);
String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString();
if (authCount.size()==NumConstant.ZERO){
log.info("未查询到该客户授权信息,先创建开放平台账号,再绑定");
//没有任何一个小程序/公众号授权,【先创建,再绑定】
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId);
// 此处的 access_token 为 【authorizer_access_token】
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String,Object> map = JSON.parseObject(data, Map.class);
openPlatformId = map.get(ModuleConstant.OPEN_APP_ID).toString();
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode((Integer)map.get(ModuleConstant.ERR_CODE));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString());
createOpen.setOpenAppId(map.get(ModuleConstant.OPEN_APP_ID).toString());
switch (createOpen.getErrCode()){
case NumConstant.ZERO:
log.info(CREATE_AND_BIND_SUCCESS);
CreateOpenFormDTO coForm = new CreateOpenFormDTO();
coForm.setOpenid(map.get(ModuleConstant.OPEN_APP_ID).toString());
coForm.setCustomerId(customerId);
//插入 open_platform_account 表
openPlatformAccountDao.insertOpenPlatFormAccount(coForm);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
}
}else if (authCount.size()>NumConstant.ZERO && !authCount.contains(authAppId)){
log.info("该客户已创建过开放平台账号,直接绑定");
JSONObject jsonObject = new JSONObject();
jsonObject.put(ModuleConstant.LOW_APP_ID,authAppId);
jsonObject.put(ModuleConstant.OPEN_APP_ID,openPlatformId);
String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_BIND_OPEN + authorizerAccessToken, JSON.toJSONString(jsonObject)).getData();
Map<String,Object> map = JSON.parseObject(data, Map.class);
CreateOpenResultDTO createOpen = new CreateOpenResultDTO();
createOpen.setErrCode((Integer)map.get(ModuleConstant.ERR_CODE));
createOpen.setErrMsg(map.get(ModuleConstant.ERR_MSG).toString());
switch (createOpen.getErrCode()){
case NumConstant.ZERO:
log.info(BIND_SUCCESS);
break;
case NumConstant.ONE_NEG:
throw new RenException(SYSTEM_ERROR);
case ModuleConstant.FORTY_THOUSAND_AND_THIRTEEN:
throw new RenException(INVALID_APP_ID);
case ModuleConstant.EIGHTY_NINE_THOUSAND:
throw new RenException(ACCOUNT_HAS_BOUND_OPEN);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_ONE:
throw new RenException(NOT_SAME_CONTRACTOR);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_THREE:
throw new RenException(NOT_ALLOWED_OPERATE);
case ModuleConstant.EIGHTY_NINE_THOUSAND_AND_FOUR:
throw new RenException(TO_LIMIT);
}
}
//插入 binding_account
BindingAccountFormDTO bindingAccount = new BindingAccountFormDTO();
bindingAccount.setOpenPlatformAccountId(openPlatformId);
bindingAccount.setAuthAppId(authAppId);
bindingAccount.setClientType(clientType);
bindingAccount.setCustomerId(customerId);
bindingAccountDao.insertBindingAccount(bindingAccount);
log.info("创建绑定账号结束");
}
/**
* @Description map Entity
* @param map

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

@ -143,4 +143,11 @@ public interface WxMaCodeConstant {
* 新增临时素材
*/
String MEDIA_UPLOAD_URL = "https://api.weixin.qq.com/wxa/setwebviewdomain";
/**
* 新增临时素材
*/
String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxa/gettemplatelist";
}

101
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaCodeSubmitAuditRequest.java

@ -1,5 +1,6 @@
package com.epmet.wxapi.param;
import com.epmet.dto.form.SubmitAuditFormDTO;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -36,110 +37,16 @@ public class WxMaCodeSubmitAuditRequest implements Serializable {
* 审核项列表选填至多填写 5
*/
@SerializedName("item_list")
private List<ItemListBean> itemList;
private List<SubmitAuditFormDTO.ItemListBean> itemList;
/**
* 预览信息小程序页面截图和操作录屏
*/
@SerializedName("preview_info")
private List<PreviewInfoBean> previewInfo;
private List<SubmitAuditFormDTO.PreviewInfoBean> previewInfo;
/**
* 用户生成内容场景UGC信息安全声明
*/
@SerializedName("ugc_declare")
private List<UgcDeclareBean> ugcDeclare;
private SubmitAuditFormDTO.UgcDeclareBean ugcDeclare;
@NoArgsConstructor
@Data
private static class ItemListBean {
/**
* 小程序的页面可通过获取小程序的页面列表接口获得
*/
@SerializedName("address")
private String address;
/**
* 小程序的标签用空格分隔标签至多 10 标签长度至多 20
*/
@SerializedName("tag")
private String tag;
/**
* 一级类目名称
*/
@SerializedName("first_class")
private String firstClass;
/**
* 二级类目名称
*/
@SerializedName("second_class")
private String secondClass;
/**
* 三级类目名称
*/
@SerializedName("third_class")
private String thirdClass;
/**
* 一级类目的 ID
*/
@SerializedName("first_id")
private String firstId;
/**
* 二级类目的 ID
*/
@SerializedName("second_id")
private String secondId;
/**
* 三级类目的 ID
*/
@SerializedName("third_id")
private String thirdId;
/**
* 小程序页面的标题,标题长度至多 32
*/
@SerializedName("title")
private String title;
}
@NoArgsConstructor
@Data
private static class PreviewInfoBean {
/**
* 录屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("Video_id_list")
private List<String> videoIdList;
/**
* 截屏mediaid列表可以通过提审素材上传接口获得
*/
@SerializedName("pic_id_list")
private List<String> picIdList;
}
@NoArgsConstructor
@Data
private static class UgcDeclareBean {
/**
* UGC场景 0,不涉及用户生成内容, 1.用户资料,2.图片,3.视频,4.文本,5其他, 可多选,当scene填0时无需填写下列字段
*/
@SerializedName("scene")
private List<Integer> scene;
/**
* 当scene选其他时的说明,不超时256字
*/
@SerializedName("other_scene_desc")
private String otherSceneDesc;
/**
* 内容安全机制 1.使用平台建议的内容安全API,2.使用其他的内容审核产品,3.通过人工审核把关,4.未做内容审核把关
*/
@SerializedName("method")
private List<Integer> method;
/**
* 是否有审核团队, 0.,1.,默认0
*/
@SerializedName("has_audit_team")
private Integer hasAuditTeam;
/**
* 说明当前对UGC内容的审核机制,不超过256字
*/
@SerializedName("audit_desc")
private String auditDesc;
}
}

23
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxMaDomainDTO.java

@ -0,0 +1,23 @@
package com.epmet.wxapi.param;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author zhaoqifeng
* @dscription
* @date 2020/7/17 17:44
*/
@Data
@Component
@ConfigurationProperties(prefix = "third.domain")
public class WxMaDomainDTO {
private List<String> requestDomain;
private List<String> wsRequestDomain;
private List<String> uploadDomain;
private List<String> downloadDomain;
private List<String> webviewDomain;
}

35
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaCodeServiceImpl.java

@ -10,14 +10,19 @@ import com.epmet.wxapi.result.*;
import com.epmet.wxapi.service.WxMaCodeService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.File;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
@ -30,21 +35,14 @@ import java.util.List;
public class WxMaCodeServiceImpl implements WxMaCodeService {
private static final String ERR_CODE = "errcode";
private static final String ERR_MSG = "errmsg";
@Value("${third.domain.requestdomain}")
private List<String> requestDomain;
@Value("${third.domain.wsrequestdomain}")
private List<String> wsRequestDomain;
@Value("${third.domain.uploaddomain}")
private List<String> uploadDomain;
@Value("${third.domain.downloaddomain}")
private List<String> downloadDomain;
@Value("${third.domain.webviewdomain}")
private List<String> webviewDomain;
@Autowired
private WxMaDomainDTO wxMaDomainDTO;
@Override
public WxResult<List<WxMaTemplateResult>> getTemplateList(String accessToken) {
WxResult<List<WxMaTemplateResult>> result = new WxResult<>();
String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken;
String url = WxMaCodeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken;
Result<String> templateListResult = HttpClientManager.getInstance().sendGet(url, null);
if (!templateListResult.success()) {
result.setErrorCode(templateListResult.getCode());
@ -54,7 +52,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
Gson gson = new Gson();
WxMaTemplateListResult templateList = gson.fromJson(templateListResult.getData(), WxMaTemplateListResult.class);
result.setErrorCode(templateList.getErrCode());
result.setErrorMsg(templateList.getErrMsg());
result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(templateList.getErrCode()));
result.setData(templateList.getTemplateList());
return result;
}
@ -153,7 +151,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
@Override
public WxResult<WxMaAuditStatusResult> getAuditStatus(String accessToken, WxMaCodeAuditStatusReq request) {
WxResult<WxMaAuditStatusResult> result = new WxResult<>();
String url = WxMaCodeConstant.COMMIT_URL + "?" + "access_token=" + accessToken;
String url = WxMaCodeConstant.GET_AUDIT_STATUS_URL + "?" + "access_token=" + accessToken;
Result<String> statusResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!statusResult.success()) {
result.setErrorCode(statusResult.getCode());
@ -213,6 +211,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
return result;
}
Gson gson = new Gson();
InputStream inputStream = gson.fromJson(statusResult.getData(), InputStream.class);
WxMaNewsResult newsResult = gson.fromJson(statusResult.getData(), WxMaNewsResult.class);
result.ok(newsResult);
return result;
@ -224,10 +223,10 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
String url = WxMaCodeConstant.MODIFY_DOMAIN_URL + "?" + "access_token=" + accessToken;
WxMaModifyDomainReq request = new WxMaModifyDomainReq();
request.setAction("set");
request.setRequestDomain(requestDomain);
request.setUploadDomain(uploadDomain);
request.setWsRequestDomain(wsRequestDomain);
request.setDownloadDomain(downloadDomain);
request.setRequestDomain(wxMaDomainDTO.getRequestDomain());
request.setUploadDomain(wxMaDomainDTO.getUploadDomain());
request.setWsRequestDomain(wxMaDomainDTO.getWsRequestDomain());
request.setDownloadDomain(wxMaDomainDTO.getDownloadDomain());
Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!modifyResult.success()) {
result.setErrorCode(modifyResult.getCode());
@ -246,7 +245,7 @@ public class WxMaCodeServiceImpl implements WxMaCodeService {
String url = WxMaCodeConstant.SET_WEBVIEW_DOMAIN_URL + "?" + "access_token=" + accessToken;
WxMaSetWebviewDomainReq request = new WxMaSetWebviewDomainReq();
request.setAction("set");
request.setWebViewDomain(webviewDomain);
request.setWebViewDomain(wxMaDomainDTO.getWebviewDomain());
Result<String> modifyResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request));
if (!modifyResult.success()) {
result.setErrorCode(modifyResult.getCode());

15
epmet-module/epmet-third/epmet-third-server/src/main/resources/bootstrap.yml

@ -105,8 +105,13 @@ third:
aesKey: d6dbde92c67e11eabac1c03fd56f7847qazxswedcvg
token: 1ae5f230c67f11eabac1c03fd56f7847
domain:
requestdomain: "https://epmet-cloud.elinkservice.cn"
wsrequestdomain: "https://epmet-cloud.elinkservice.cn"
uploaddomain: "https://epmet-cloud.elinkservice.cn"
downloaddomain: "https://epmet-cloud.elinkservice.cn"
webviewdomain: "https://epmet-cloud.elinkservice.cn"
requestDomain:
- https://epmet-cloud.elinkservice.cn
wsRequestDomain:
- https://epmet-cloud.elinkservice.cn
uploadDomain:
- https://epmet-cloud.elinkservice.cn
downloadDomain:
- https://epmet-cloud.elinkservice.cn
webviewDomain:
- https://epmet-cloud.elinkservice.cn

2
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml

@ -41,7 +41,6 @@
WHERE
del_flag = 0
AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) <![CDATA[ <= ]]> 900
AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) > 0
</select>
<!-- 插入 authorizer_access_token -->
@ -68,6 +67,7 @@
<update id="updateOldAuthorizerAccessToken">
update authorization_info set del_flag = 1 where customer_id = #{customerId} AND client_type = #{clientType}
</update>
<select id="getAuthInfoByCustomer" resultType="com.epmet.dto.AuthorizationInfoDTO">
SELECT AUTHORIZER_APPID,
AUTHORIZER_ACCESS_TOKEN

2
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/BindingAccountDao.xml

@ -15,7 +15,7 @@
#{clientType},
#{delFlag},
#{revision},
#{createDBy},
#{createdBy},
NOW(),
#{updatedBy},
NOW()

4
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeCustomerDao.xml

@ -31,8 +31,8 @@
cc.USER_VERSION AS "version",
cc.USER_DESC AS "codeInfo",
cc.STATUS,
DATE_FORMAT(cc.CREATED_TIME,'%Y-%m-%d') AS "uploadTime",
IFNULL(DATE_FORMAT(car.CREATED_TIME,'%Y-%m-%d'),'') AS "auditTime",
DATE_FORMAT(cc.CREATED_TIME,'%Y-%m-%d %T') AS "uploadTime",
IFNULL(DATE_FORMAT(car.CREATED_TIME,'%Y-%m-%d %T'),'') AS "auditTime",
car.AUDIT_ID
FROM code_customer cc
LEFT JOIN code_audit_result car ON cc.ID = car.CODE_ID AND car.DEL_FLAG = '0'

6
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CodeOperationHistoryDao.xml

@ -9,7 +9,7 @@
<result property="codeId" column="CODE_ID"/>
<result property="version" column="VERSION"/>
<result property="operation" column="OPERATION"/>
<result property="describe" column="DESCRIBE"/>
<result property="description" column="DESCRIPTION"/>
<result property="revision" column="REVISION"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="createdBy" column="CREATED_BY"/>
@ -19,7 +19,7 @@
</resultMap>
<update id="updateDescribeByCodeId">
UPDATE code_operation_history SET
`DESCRIBE` = #{describe}
`DESCRIPTION` = #{describe}
WHERE CODE_ID = #{codeId}
AND OPERATION = 'audit'
</update>
@ -28,7 +28,7 @@
DATE_FORMAT(coh.CREATED_TIME, '%Y-%m-%d') AS "operationTime",
coh.VERSION,
coh.OPERATION,
coh.`DESCRIBE`
coh.`DESCRIPTION`
FROM code_operation_history coh
INNER JOIN code_customer cc ON coh.CODE_ID = cc.ID
WHERE

2
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml

@ -28,7 +28,7 @@
COMPONENT_ACCESS_TOKEN
FROM
component_access_token
WHERE delFlag = '0'
WHERE DEL_FLAG = '0'
</select>
<!-- 查询component_access_token 数量 -->

4
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/CustomerMpDao.xml

@ -19,9 +19,9 @@
client ASC
</select>
<!-- 查询授权的数量 -->
<select id="selectAuthCount" resultType="java.lang.Integer">
<select id="selectAuthCount" resultType="java.lang.String">
SELECT
COUNT(*) AS notAuthCount
app_id AS authAppId
FROM
customer_mp
WHERE

4
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/OpenFlatformAccountDao.xml

@ -12,7 +12,7 @@
VALUES
(
REPLACE ( UUID(), '-', '' ),
#{openAppId},
#{openid},
#{customerId},
#{delFlag},
#{revision},
@ -28,7 +28,7 @@
SELECT
open_app_id AS openAppId
FROM
open_flatform_account
open_platform_account
WHERE
del_flag = 0
AND customer_id = #{customerId}

2
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

@ -21,6 +21,6 @@ public interface OperCrmOpenFeignClient {
* @param dto
* @return
*/
@PostMapping("/oper/crm/getcostomerInfo")
@PostMapping("/oper/crm/customer/getcostomerInfo")
Result<CustomerDTO> getCustomerInfo(CustomerDTO dto);
}

Loading…
Cancel
Save