# Conflicts: # open-api/src/main/java/com/iformall/dto/PreviewVideoDTO.java # suimangCApi/src/main/resources/application-dev.yml # suimangCApi/src/main/resources/application-prod.ymlprivate_deployment
| @@ -1,61 +1,61 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import springfox.documentation.builders.ApiInfoBuilder; | |||
| import springfox.documentation.builders.ParameterBuilder; | |||
| import springfox.documentation.builders.PathSelectors; | |||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||
| import springfox.documentation.schema.ModelRef; | |||
| import springfox.documentation.service.ApiInfo; | |||
| import springfox.documentation.service.Parameter; | |||
| import springfox.documentation.spi.DocumentationType; | |||
| import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| import springfox.documentation.spring.web.plugins.Docket; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| import javax.servlet.ServletContext; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| //参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| @Configuration | |||
| @EnableSwagger2 | |||
| public class Swagger2Config { | |||
| @Autowired | |||
| private ServletContext servletContext; | |||
| @Bean | |||
| public Docket createRestApi() { | |||
| ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| List<Parameter> pars = new ArrayList<Parameter>(); | |||
| //增加一个request的header参数 | |||
| tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| pars.add(tokenPar.build()); | |||
| return new Docket(DocumentationType.SWAGGER_2) | |||
| .apiInfo(apiInfo()) | |||
| .select() | |||
| .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| .paths(PathSelectors.any()) | |||
| .build() | |||
| .globalOperationParameters(pars) | |||
| .pathProvider(new RelativePathProvider(servletContext) { | |||
| @Override | |||
| public String getApplicationBasePath() { | |||
| return "/api"; | |||
| } | |||
| }); | |||
| } | |||
| private ApiInfo apiInfo() { | |||
| return new ApiInfoBuilder() | |||
| .title("c端 api") | |||
| .description("c api") | |||
| .termsOfServiceUrl("http://localhost:7000") | |||
| .version("2.0") | |||
| .build(); | |||
| } | |||
| } | |||
| //package com.iformall.config; | |||
| // | |||
| //import org.springframework.beans.factory.annotation.Autowired; | |||
| //import org.springframework.context.annotation.Bean; | |||
| //import org.springframework.context.annotation.Configuration; | |||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||
| //import springfox.documentation.builders.ParameterBuilder; | |||
| //import springfox.documentation.builders.PathSelectors; | |||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||
| //import springfox.documentation.schema.ModelRef; | |||
| //import springfox.documentation.service.ApiInfo; | |||
| //import springfox.documentation.service.Parameter; | |||
| //import springfox.documentation.spi.DocumentationType; | |||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| //import springfox.documentation.spring.web.plugins.Docket; | |||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| // | |||
| //import javax.servlet.ServletContext; | |||
| //import java.util.ArrayList; | |||
| //import java.util.List; | |||
| // | |||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| //@Configuration | |||
| //@EnableSwagger2 | |||
| //public class Swagger2Config { | |||
| // | |||
| // @Autowired | |||
| // private ServletContext servletContext; | |||
| // | |||
| // @Bean | |||
| // public Docket createRestApi() { | |||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||
| // //增加一个request的header参数 | |||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| // pars.add(tokenPar.build()); | |||
| // return new Docket(DocumentationType.SWAGGER_2) | |||
| // .apiInfo(apiInfo()) | |||
| // .select() | |||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| // .paths(PathSelectors.any()) | |||
| // .build() | |||
| // .globalOperationParameters(pars) | |||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||
| // @Override | |||
| // public String getApplicationBasePath() { | |||
| // return "/api"; | |||
| // } | |||
| // }); | |||
| // } | |||
| // | |||
| // private ApiInfo apiInfo() { | |||
| // return new ApiInfoBuilder() | |||
| // .title("c端 api") | |||
| // .description("c api") | |||
| // .termsOfServiceUrl("http://localhost:7000") | |||
| // .version("2.0") | |||
| // .build(); | |||
| // } | |||
| // | |||
| //} | |||
| @@ -45,7 +45,9 @@ public class WebMvcConfig implements WebMvcConfigurer { | |||
| @Override | |||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||
| registry.addResourceHandler("swagger-ui.html") | |||
| // registry.addResourceHandler("swagger-ui.html") | |||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("doc.html") | |||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("/webjars/**") | |||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||
| @@ -5,9 +5,39 @@ import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| /** | |||
| * @author xmzhao71 | |||
| * @date 2023-10-27 | |||
| */ | |||
| @ApiModel(value = "生成视频请求参数") | |||
| @Data | |||
| public class GenerateVideoDTO { | |||
| /** | |||
| * 请求参数 | |||
| * { | |||
| * "gen_txt":"大家好,我是渣渣辉。是兄弟就来贪玩蓝月砍我一刀。望我,再望我,还望我,再望我就把你喝掉。", | |||
| * "video_template_id":"16938690720846922_vorSBabt", | |||
| * "voice_id":"zh-CN-XiaomengNeural", | |||
| * "voice_style":"chat", | |||
| * "video_files":{ | |||
| * "back_ground":{ | |||
| * "image":"", | |||
| * "type":"vertical" | |||
| * }, | |||
| * "digital_human":{ | |||
| * "coord":[ | |||
| * -202, | |||
| * 7 | |||
| * ], | |||
| * "level":1, | |||
| * "ratio":1.3 | |||
| * } | |||
| * }, | |||
| * "subtitle":{ | |||
| * "enabled":0 | |||
| * } | |||
| * } | |||
| */ | |||
| @ApiModelProperty(value = "视频唯一标识") | |||
| private Long id; | |||
| @ApiModelProperty(value = "生成视频参数") | |||
| @@ -25,12 +25,15 @@ public class PreviewVideoDTO { | |||
| private String voiceId; | |||
| @ApiModelProperty("声音风格名称") | |||
| private String voiceStyle; | |||
| @ApiModelProperty("性别(male:男,female:女)") | |||
| private String gender; | |||
| public static AiPreviewParam mappingParam(PreviewVideoDTO dto) { | |||
| AiPreviewParam aiPreviewParam = new AiPreviewParam(); | |||
| aiPreviewParam.setGen_txt(dto.getPaperwork()); | |||
| aiPreviewParam.setVoice_id(dto.getVoiceId()); | |||
| aiPreviewParam.setVoice_style(dto.getVoiceStyle()); | |||
| aiPreviewParam.setGender(dto.getGender()); | |||
| return aiPreviewParam; | |||
| } | |||
| } | |||
| @@ -38,6 +38,9 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| if (true) { | |||
| return true; | |||
| } | |||
| response.setHeader("Content-type", "application/json;charset=UTF-8"); | |||
| @@ -68,7 +71,6 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| } | |||
| try{ | |||
| logger.info("请求body{}--"+body); | |||
| // JSONObject parameterMap = JSON.parseObject(body); | |||
| Map<String, Object> parameterMap = JSONObject.parseObject(body, Map.class); | |||
| if(parameterMap.isEmpty()){ | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"参数格式不正确"); | |||
| @@ -1,6 +1,6 @@ | |||
| package com.iformall.service.impl; | |||
| import com.iformall.domain.dto.neuver.SaveServiceVideoRecordDTO; | |||
| import com.iformall.domain.dto.sm.SaveServiceVideoRecordDTO; | |||
| import com.iformall.service.AiVideoService; | |||
| import com.iformall.service.sm.ServiceVideoRecordService; | |||
| import com.iformall.sm.*; | |||
| @@ -204,8 +204,9 @@ logging: | |||
| suimang: | |||
| oral_broadcasting: http://111.198.0.15:22266 | |||
| video_tts: http://111.198.0.15:22222 | |||
| photo_speak: http://111.198.0.15:22299 | |||
| photo_speak_hy: http://111.198.0.15:22288 | |||
| digital_avatar: http://111.198.0.15:22200 | |||
| digital_avatar: http://nas.pucao.cn:2005 | |||
| digital_avatar_hy: http://nas.pucao.cn:2003 | |||
| callbackUrl: https://test.metavatar.cc/C | |||
| callbackUrl: https://mtest.metavatar.cc/C | |||
| @@ -21,6 +21,7 @@ | |||
| <module>suimangSchedule</module> | |||
| <module>suimangMQConsumer</module> | |||
| <module>open-api</module> | |||
| <module>suimang-swagger</module> | |||
| </modules> | |||
| <parent> | |||
| @@ -186,21 +187,21 @@ | |||
| </dependency> | |||
| <!-- Swagger --> | |||
| <dependency> | |||
| <groupId>io.springfox</groupId> | |||
| <artifactId>springfox-swagger2</artifactId> | |||
| <version>2.8.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>io.springfox</groupId> | |||
| <artifactId>springfox-swagger-ui</artifactId> | |||
| <version>2.8.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>io.springfox</groupId> | |||
| <artifactId>springfox-spring-web</artifactId> | |||
| <version>2.8.0</version> | |||
| </dependency> | |||
| <!-- <dependency>--> | |||
| <!-- <groupId>io.springfox</groupId>--> | |||
| <!-- <artifactId>springfox-swagger2</artifactId>--> | |||
| <!-- <version>2.8.0</version>--> | |||
| <!-- </dependency>--> | |||
| <!-- <dependency>--> | |||
| <!-- <groupId>io.springfox</groupId>--> | |||
| <!-- <artifactId>springfox-swagger-ui</artifactId>--> | |||
| <!-- <version>2.8.0</version>--> | |||
| <!-- </dependency>--> | |||
| <!-- <dependency>--> | |||
| <!-- <groupId>io.springfox</groupId>--> | |||
| <!-- <artifactId>springfox-spring-web</artifactId>--> | |||
| <!-- <version>2.8.0</version>--> | |||
| <!-- </dependency>--> | |||
| <dependency> | |||
| <groupId>com.fasterxml.jackson.core</groupId> | |||
| <artifactId>jackson-core</artifactId> | |||
| @@ -0,0 +1,28 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <parent> | |||
| <artifactId>suimang</artifactId> | |||
| <groupId>com.iformall</groupId> | |||
| <version>1.0</version> | |||
| </parent> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <artifactId>suimang-swagger</artifactId> | |||
| <dependencies> | |||
| <!--swagger 相关依赖--> | |||
| <dependency> | |||
| <groupId>io.springfox</groupId> | |||
| <artifactId>springfox-swagger2</artifactId> | |||
| <version>2.9.2</version> | |||
| </dependency> | |||
| <!--doc.html模式--> | |||
| <dependency> | |||
| <groupId>com.github.xiaoymin</groupId> | |||
| <artifactId>swagger-bootstrap-ui</artifactId> | |||
| <version>1.9.3</version> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -0,0 +1,19 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.ElementType; | |||
| import java.lang.annotation.Retention; | |||
| import java.lang.annotation.RetentionPolicy; | |||
| import java.lang.annotation.Target; | |||
| @Target(ElementType.METHOD) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| public @interface ApiVersion { | |||
| /** | |||
| * 接口版本号(对应swagger中的group) | |||
| * | |||
| * @return String[] | |||
| */ | |||
| String[] group(); | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.annotation; | |||
| import com.iformall.config.SwaggerConfiguration; | |||
| import org.springframework.context.annotation.Import; | |||
| import java.lang.annotation.*; | |||
| @Target({ElementType.TYPE}) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| @Documented | |||
| @Inherited | |||
| @Import({SwaggerConfiguration.class}) | |||
| public @interface BaseEnableSwagger { | |||
| } | |||
| @@ -0,0 +1,94 @@ | |||
| package com.iformall.config; | |||
| import com.google.common.base.Predicate; | |||
| import com.google.common.base.Predicates; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | |||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | |||
| import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import springfox.documentation.builders.ApiInfoBuilder; | |||
| import springfox.documentation.builders.PathSelectors; | |||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||
| import springfox.documentation.service.ApiInfo; | |||
| import springfox.documentation.service.Contact; | |||
| import springfox.documentation.spi.DocumentationType; | |||
| import springfox.documentation.spring.web.plugins.Docket; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| import javax.servlet.ServletContext; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| @Configuration | |||
| @EnableSwagger2 | |||
| @EnableAutoConfiguration | |||
| @EnableConfigurationProperties(SwaggerProperties.class) | |||
| @ConditionalOnProperty(name = "swagger.enabled", matchIfMissing = true) | |||
| public class SwaggerConfiguration { | |||
| private static final List<String> DEFAULT_EXCLUDE_PATH = Arrays.asList("/error"); | |||
| private static final String BASE_PATH = "/**"; | |||
| @Autowired | |||
| private SwaggerProperties swaggerProperties; | |||
| /** | |||
| * 1、分组 | |||
| * 2、切换分组,修改访问/v2/api-docs/ 接口的路径 | |||
| * https://admintest.malls.iformall.com/v2/api-docs/ | |||
| * https://admintest.malls.iformall.com/B/v2/api-docs/ | |||
| * | |||
| * @param servletContext | |||
| * @return {@link Docket} | |||
| */ | |||
| @Bean | |||
| public Docket docket(ServletContext servletContext) { | |||
| // base-path处理 | |||
| if (swaggerProperties.getBasePath().isEmpty()) { | |||
| swaggerProperties.getBasePath().add(BASE_PATH); | |||
| } | |||
| List<Predicate<String>> basePath = new ArrayList<>(swaggerProperties.getBasePath().size()); | |||
| swaggerProperties.getBasePath().forEach(path -> basePath.add(PathSelectors.ant(path))); | |||
| // exclude-path处理 | |||
| if (swaggerProperties.getExcludePath().isEmpty()) { | |||
| swaggerProperties.getExcludePath().addAll(DEFAULT_EXCLUDE_PATH); | |||
| } | |||
| List<Predicate<String>> excludePath = new ArrayList<>(); | |||
| swaggerProperties.getExcludePath().forEach(path -> excludePath.add(PathSelectors.ant(path))); | |||
| return new Docket(DocumentationType.SWAGGER_2) | |||
| .host(swaggerProperties.getHost()) | |||
| .apiInfo(apiInfo(swaggerProperties)).select() | |||
| .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePackage())) | |||
| .apis(input -> { | |||
| ApiVersion apiVersion = input.getHandlerMethod().getMethodAnnotation(ApiVersion.class); | |||
| return apiVersion != null && Arrays.asList(apiVersion.group()).contains(SwaggerConstant.V_1_0_0); | |||
| }) | |||
| .paths( | |||
| Predicates.and( | |||
| Predicates.not(Predicates.or(excludePath)), | |||
| Predicates.or(basePath) | |||
| ) | |||
| ) | |||
| .build(); | |||
| } | |||
| private ApiInfo apiInfo(SwaggerProperties swaggerProperties) { | |||
| return new ApiInfoBuilder() | |||
| .title(swaggerProperties.getTitle()) | |||
| .description(swaggerProperties.getDescription()) | |||
| .license(swaggerProperties.getLicense()) | |||
| .licenseUrl(swaggerProperties.getLicenseUrl()) | |||
| .termsOfServiceUrl(swaggerProperties.getTermsOfServiceUrl()) | |||
| .contact(new Contact(swaggerProperties.getContact().getName(), swaggerProperties.getContact().getUrl(), swaggerProperties.getContact().getEmail())) | |||
| .version(swaggerProperties.getVersion()) | |||
| .build(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,123 @@ | |||
| package com.iformall.config; | |||
| import lombok.Data; | |||
| import lombok.NoArgsConstructor; | |||
| import org.springframework.boot.context.properties.ConfigurationProperties; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @Data | |||
| @ConfigurationProperties("swagger") | |||
| public class SwaggerProperties { | |||
| private Map<String, String> services; | |||
| private String prePath; | |||
| /** | |||
| * 是否开启swagger | |||
| */ | |||
| private Boolean enabled; | |||
| /** | |||
| * swagger会解析的包路径 | |||
| **/ | |||
| private String basePackage = ""; | |||
| /** | |||
| * swagger会解析的url规则 | |||
| **/ | |||
| private List<String> basePath = new ArrayList<>(); | |||
| /** | |||
| * 在basePath基础上需要排除的url规则 | |||
| **/ | |||
| private List<String> excludePath = new ArrayList<>(); | |||
| /** | |||
| * 标题 | |||
| **/ | |||
| private String title = ""; | |||
| /** | |||
| * 描述 | |||
| **/ | |||
| private String description = ""; | |||
| /** | |||
| * 版本 | |||
| **/ | |||
| private String version = ""; | |||
| /** | |||
| * 许可证 | |||
| **/ | |||
| private String license = ""; | |||
| /** | |||
| * 许可证URL | |||
| **/ | |||
| private String licenseUrl = ""; | |||
| /** | |||
| * 服务条款URL | |||
| **/ | |||
| private String termsOfServiceUrl = ""; | |||
| /** | |||
| * host信息 | |||
| **/ | |||
| private String host = ""; | |||
| /** | |||
| * 联系人信息 | |||
| */ | |||
| private Contact contact = new Contact(); | |||
| /** | |||
| * 全局统一鉴权配置 | |||
| **/ | |||
| private Authorization authorization = new Authorization(); | |||
| @Data | |||
| public static class Contact { | |||
| /** | |||
| * 联系人 | |||
| **/ | |||
| private String name = ""; | |||
| /** | |||
| * 联系人url | |||
| **/ | |||
| private String url = ""; | |||
| /** | |||
| * 联系人email | |||
| **/ | |||
| private String email = ""; | |||
| } | |||
| @Data | |||
| @NoArgsConstructor | |||
| public static class Authorization { | |||
| /** | |||
| * 鉴权策略ID,需要和SecurityReferences ID保持一致 | |||
| */ | |||
| private String name = ""; | |||
| /** | |||
| * 需要开启鉴权URL的正则 | |||
| */ | |||
| private String authRegex = "^.*$"; | |||
| /** | |||
| * 鉴权作用域列表 | |||
| */ | |||
| private List<AuthorizationScope> authorizationScopeList = new ArrayList<>(); | |||
| private List<String> tokenUrlList = new ArrayList<>(); | |||
| } | |||
| @Data | |||
| @NoArgsConstructor | |||
| public static class AuthorizationScope { | |||
| /** | |||
| * 作用域名称 | |||
| */ | |||
| private String scope = ""; | |||
| /** | |||
| * 作用域描述 | |||
| */ | |||
| private String description = ""; | |||
| } | |||
| } | |||
| @@ -0,0 +1,8 @@ | |||
| package com.iformall.constant; | |||
| public interface SwaggerConstant { | |||
| /** | |||
| * | |||
| */ | |||
| String V_1_0_0 = "v1.0.0"; | |||
| } | |||
| @@ -25,6 +25,7 @@ | |||
| <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-validation:2.2.5.RELEASE" level="project" /> | |||
| <orderEntry type="library" name="Maven: jakarta.validation:jakarta.validation-api:2.0.2" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.18.Final" level="project" /> | |||
| <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.springframework:spring-web:5.2.4.RELEASE" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.springframework:spring-webmvc:5.2.4.RELEASE" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.springframework:spring-expression:5.2.4.RELEASE" level="project" /> | |||
| @@ -161,7 +162,7 @@ | |||
| <orderEntry type="library" scope="TEST" name="Maven: org.assertj:assertj-core:3.13.2" level="project" /> | |||
| <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest:2.1" level="project" /> | |||
| <orderEntry type="library" scope="TEST" name="Maven: org.mockito:mockito-core:3.1.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" /> | |||
| <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy:1.10.8" level="project" /> | |||
| <orderEntry type="library" scope="TEST" name="Maven: net.bytebuddy:byte-buddy-agent:1.10.8" level="project" /> | |||
| <orderEntry type="library" scope="TEST" name="Maven: org.objenesis:objenesis:2.6" level="project" /> | |||
| <orderEntry type="library" scope="TEST" name="Maven: org.skyscreamer:jsonassert:1.5.0" level="project" /> | |||
| @@ -184,21 +185,6 @@ | |||
| <orderEntry type="library" name="Maven: org.quartz-scheduler:quartz:2.3.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: com.mchange:mchange-commons-java:0.2.11" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.30" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-swagger2:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.swagger:swagger-annotations:1.5.14" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.swagger:swagger-models:1.5.14" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-spi:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-core:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-schema:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-common:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: com.fasterxml:classmate:1.5.1" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-core:1.2.0.RELEASE" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.springframework.plugin:spring-plugin-metadata:1.2.0.RELEASE" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.mapstruct:mapstruct:1.2.0.Final" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-swagger-ui:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: io.springfox:springfox-spring-web:2.8.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.reflections:reflections:0.9.11" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.javassist:javassist:3.21.0-GA" level="project" /> | |||
| <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.10.3" level="project" /> | |||
| <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.10.3" level="project" /> | |||
| <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.10.2" level="project" /> | |||
| @@ -239,6 +225,7 @@ | |||
| <orderEntry type="library" name="Maven: org.apache.poi:poi-ooxml-schemas:4.1.1" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.apache.xmlbeans:xmlbeans:3.1.0" level="project" /> | |||
| <orderEntry type="library" name="Maven: ognl:ognl:3.2.6" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" /> | |||
| <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> | |||
| <orderEntry type="library" name="Maven: cn.afterturn:easypoi-annotation:4.1.3.A" level="project" /> | |||
| <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot:2.2.5.RELEASE" level="project" /> | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall; | |||
| import com.iformall.annotation.BaseEnableSwagger; | |||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||
| import org.mybatis.spring.annotation.MapperScan; | |||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | |||
| @@ -18,7 +19,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| */ | |||
| @SpringBootApplication | |||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||
| @EnableSwagger2 | |||
| @BaseEnableSwagger | |||
| @EnableEncryptableProperties | |||
| @EnableAsync | |||
| @EnableRocketMQ | |||
| @@ -139,6 +139,7 @@ public class ShiroConfig { | |||
| // } | |||
| // swagger-ui | |||
| filterChainDefinitionMap.put("/swagger-ui.html", "anon"); | |||
| filterChainDefinitionMap.put("/doc.html", "anon"); | |||
| filterChainDefinitionMap.put("/v2/**", "anon"); | |||
| filterChainDefinitionMap.put("/swagger-resources/**", "anon"); | |||
| filterChainDefinitionMap.put("/webjars/**", "anon"); | |||
| @@ -1,61 +1,61 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import springfox.documentation.builders.ApiInfoBuilder; | |||
| import springfox.documentation.builders.ParameterBuilder; | |||
| import springfox.documentation.builders.PathSelectors; | |||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||
| import springfox.documentation.schema.ModelRef; | |||
| import springfox.documentation.service.ApiInfo; | |||
| import springfox.documentation.service.Parameter; | |||
| import springfox.documentation.spi.DocumentationType; | |||
| import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| import springfox.documentation.spring.web.plugins.Docket; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| import javax.servlet.ServletContext; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| //参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| @Configuration | |||
| @EnableSwagger2 | |||
| public class Swagger2Config { | |||
| @Autowired | |||
| private ServletContext servletContext; | |||
| @Bean | |||
| public Docket createRestApi() { | |||
| ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| List<Parameter> pars = new ArrayList<Parameter>(); | |||
| //增加一个request的header参数 | |||
| tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| pars.add(tokenPar.build()); | |||
| return new Docket(DocumentationType.SWAGGER_2) | |||
| .apiInfo(apiInfo()) | |||
| .select() | |||
| .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| .paths(PathSelectors.any()) | |||
| .build() | |||
| .globalOperationParameters(pars) | |||
| .pathProvider(new RelativePathProvider(servletContext) { | |||
| @Override | |||
| public String getApplicationBasePath() { | |||
| return "/api"; | |||
| } | |||
| }); | |||
| } | |||
| private ApiInfo apiInfo() { | |||
| return new ApiInfoBuilder() | |||
| .title("a端 api") | |||
| .description("a api") | |||
| .termsOfServiceUrl("http://localhost:7000") | |||
| .version("2.0") | |||
| .build(); | |||
| } | |||
| } | |||
| //package com.iformall.config; | |||
| // | |||
| //import org.springframework.beans.factory.annotation.Autowired; | |||
| //import org.springframework.context.annotation.Bean; | |||
| //import org.springframework.context.annotation.Configuration; | |||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||
| //import springfox.documentation.builders.ParameterBuilder; | |||
| //import springfox.documentation.builders.PathSelectors; | |||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||
| //import springfox.documentation.schema.ModelRef; | |||
| //import springfox.documentation.service.ApiInfo; | |||
| //import springfox.documentation.service.Parameter; | |||
| //import springfox.documentation.spi.DocumentationType; | |||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| //import springfox.documentation.spring.web.plugins.Docket; | |||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| // | |||
| //import javax.servlet.ServletContext; | |||
| //import java.util.ArrayList; | |||
| //import java.util.List; | |||
| // | |||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| //@Configuration | |||
| //@EnableSwagger2 | |||
| //public class Swagger2Config { | |||
| // | |||
| // @Autowired | |||
| // private ServletContext servletContext; | |||
| // | |||
| // @Bean | |||
| // public Docket createRestApi() { | |||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||
| // //增加一个request的header参数 | |||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| // pars.add(tokenPar.build()); | |||
| // return new Docket(DocumentationType.SWAGGER_2) | |||
| // .apiInfo(apiInfo()) | |||
| // .select() | |||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| // .paths(PathSelectors.any()) | |||
| // .build() | |||
| // .globalOperationParameters(pars) | |||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||
| // @Override | |||
| // public String getApplicationBasePath() { | |||
| // return "/api"; | |||
| // } | |||
| // }); | |||
| // } | |||
| // | |||
| // private ApiInfo apiInfo() { | |||
| // return new ApiInfoBuilder() | |||
| // .title("a端 api") | |||
| // .description("a api") | |||
| // .termsOfServiceUrl("http://localhost:7000") | |||
| // .version("2.0") | |||
| // .build(); | |||
| // } | |||
| // | |||
| //} | |||
| @@ -100,7 +100,9 @@ public class WebConfig implements WebMvcConfigurer { | |||
| @Override | |||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||
| registry.addResourceHandler("swagger-ui.html") | |||
| // registry.addResourceHandler("swagger-ui.html") | |||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("doc.html") | |||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("/webjars/**") | |||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||
| @@ -814,76 +814,6 @@ public class WxProjectConfigController extends BaseController { | |||
| } | |||
| } | |||
| @ApiOperation("获取抖音支付2.0 回调接口配置") | |||
| @GetMapping("/ttcallback/query/settings") | |||
| @SystemControllerLog(description = "") | |||
| @TenantIgnore | |||
| public ResultData ttcallbackQuerySettings(String appid) { | |||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackQuerySettings"); | |||
| try { | |||
| WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||
| if(appinfo == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | |||
| } | |||
| if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); | |||
| if(payAccount == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的支付数据"); | |||
| } | |||
| TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||
| CallBackSettingsRequest callBackSettingsRequest = ttPayService.querySettings(); | |||
| return new ResultData(callBackSettingsRequest); | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| @ApiOperation("配置抖音支付2.0 回调接口") | |||
| @PostMapping("/ttcallback/settings") | |||
| @SystemControllerLog(description = "商场集团-更新") | |||
| @TenantIgnore | |||
| public ResultData ttcallbackSettings(@RequestBody Map<String, String> map) { | |||
| logger.debug("[" + getIpAddr() + "] WxProjectConfigController::ttcallbackSettings"); | |||
| String appid = map.get("appid"); | |||
| String create_order_callback = map.get("createOrderCallback"); | |||
| String refund_callback = map.get("refundCallback"); | |||
| String delivery_qrcode_redirect = map.get("deliveryQrcodeRedirect"); | |||
| if(StringUtils.isBlank(appid) || StringUtils.isBlank(create_order_callback) | |||
| || StringUtils.isBlank(refund_callback)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| try { | |||
| WxAppinfo appinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||
| if(appinfo == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的小程序"); | |||
| } | |||
| if(!EnumAppPlat.TOUTIAO.getCode().equals(appinfo.getPlat()) | |||
| || !EnumAppType.C.getCode().equals(appinfo.getType())){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"该小程序不支持"); | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); | |||
| if(payAccount == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"未找到对应的支付数据"); | |||
| } | |||
| TtPayService ttPayService = maUtil.getTtPayService(appinfo, payAccount); | |||
| CallBackSettingsRequest request = new CallBackSettingsRequest(); | |||
| request.setCreateOrderCallback(create_order_callback); | |||
| request.setRefundCallback(refund_callback); | |||
| request.setDeliveryQrcodeRedirect(delivery_qrcode_redirect); | |||
| boolean b = ttPayService.callbackSettings(request); | |||
| if(b){ | |||
| return new ResultData(); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| }catch (Exception e){ | |||
| logger.error(e.getMessage(),e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,47 @@ | |||
| package com.iformall.controller.sm; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.common.R; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.domain.dto.sm.SaveApiGuideDTO; | |||
| import com.iformall.domain.dto.sm.UpdateApiGuideDTO; | |||
| import com.iformall.domain.po.sm.ApiGuide; | |||
| import com.iformall.service.sm.ApiGuideService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("/apiGuide") | |||
| @Api(tags = "api指南接口") | |||
| public class ApiGuideController { | |||
| @Autowired | |||
| private ApiGuideService apiGuideService; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("分页查询api指南") | |||
| @GetMapping("/page") | |||
| public R<PageInfo<ApiGuide>> pageApiGuide(ApiGuide apiGuide, Integer pageNum, Integer pageSize) { | |||
| return R.ok(apiGuideService.pageApiGuide(apiGuide, pageNum, pageSize)); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("新增api指南") | |||
| @PostMapping("/save") | |||
| public R<Void> saveApiGuide(@RequestBody SaveApiGuideDTO dto) { | |||
| apiGuideService.saveApiGuide(dto); | |||
| return R.ok(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("修改api指南") | |||
| @PostMapping("/update") | |||
| public R<Void> updateApiGuide(@RequestBody UpdateApiGuideDTO dto) { | |||
| apiGuideService.updateApiGuide(dto); | |||
| return R.ok(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,69 @@ | |||
| package com.iformall.controller.sm; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.R; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.domain.dto.sm.SaveApiMenuDTO; | |||
| import com.iformall.domain.dto.sm.UpdateApiMenuDTO; | |||
| import com.iformall.domain.po.sm.ApiMenu; | |||
| import com.iformall.domain.vo.sm.ApiMenuVO; | |||
| import com.iformall.exception.BizException; | |||
| import com.iformall.service.sm.ApiMenuService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("/apiMenu") | |||
| @Api(tags = "api菜单接口") | |||
| public class ApiMenuController { | |||
| @Autowired | |||
| private ApiMenuService apiMenuService; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("分页查询api菜单") | |||
| @GetMapping("/page") | |||
| public R<PageInfo<ApiMenuVO>> pageApiMenu(ApiMenu ApiMenu, Integer pageNum, Integer pageSize) { | |||
| return R.ok(apiMenuService.pageApiMenu(ApiMenu, pageNum, pageSize)); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("单个查询api菜单") | |||
| @GetMapping("/get") | |||
| public R<ApiMenuVO> getApiMenu(Long id) { | |||
| if (id == null) { | |||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return R.ok(apiMenuService.getApiMenu(id)); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("新增api菜单") | |||
| @PostMapping("/save") | |||
| public R<Void> saveApiMenu(@RequestBody SaveApiMenuDTO dto) { | |||
| apiMenuService.saveApiMenu(dto); | |||
| return R.ok(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("修改api菜单") | |||
| @PostMapping("/update") | |||
| public R<Void> updateApiMenu(@RequestBody UpdateApiMenuDTO dto) { | |||
| apiMenuService.updateApiMenu(dto); | |||
| return R.ok(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("全查询父级api菜单") | |||
| @GetMapping("/listParentMenu") | |||
| public R<List<ApiMenu>> listParentMenu() { | |||
| return R.ok(apiMenuService.listParentMenu()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,57 @@ | |||
| package com.iformall.controller.sm; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.common.R; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.sm.SaveServiceInfoDTO; | |||
| import com.iformall.domain.dto.sm.UpdateServiceInfoDTO; | |||
| import com.iformall.domain.dto.sm.UpdateServiceInfoStatusDTO; | |||
| import com.iformall.domain.po.sm.ServiceInfo; | |||
| import com.iformall.service.sm.ServiceInfoService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("/serviceInfo") | |||
| @Api(tags = "合作商接口") | |||
| public class ServiceInfoController extends BaseController { | |||
| @Autowired | |||
| private ServiceInfoService serviceInfoService; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("分页查询合作商") | |||
| @GetMapping("/page") | |||
| public R<PageInfo<ServiceInfo>> pageServiceInfo(ServiceInfo serviceInfo, Integer pageNum, Integer pageSize) { | |||
| return R.ok(serviceInfoService.pageServiceInfo(serviceInfo, pageNum, pageSize)); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("新增合作商") | |||
| @PostMapping("/save") | |||
| public R<Void> saveServiceInfo(@RequestBody SaveServiceInfoDTO dto) { | |||
| serviceInfoService.saveServiceInfo(dto); | |||
| return R.ok(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("修改合作商") | |||
| @PostMapping("/update") | |||
| public R<Void> updateServiceInfo(@RequestBody UpdateServiceInfoDTO dto) { | |||
| serviceInfoService.updateServiceInfo(dto); | |||
| return R.ok(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("修改合作商状态") | |||
| @PostMapping("/updateStatus") | |||
| public R<Void> updateServiceInfoStatus(@RequestBody UpdateServiceInfoStatusDTO dto) { | |||
| serviceInfoService.updateServiceInfoStatus(dto); | |||
| return R.ok(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,50 @@ | |||
| package com.iformall.controller.sm; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.R; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | |||
| import com.iformall.domain.po.WxThirdPartyApi; | |||
| import com.iformall.exception.BizException; | |||
| import com.iformall.service.WxThirdPartyApiService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("/thirdPartyApi") | |||
| @Api(tags = "秘钥接口") | |||
| public class ThirdPartyApiController { | |||
| @Autowired | |||
| private WxThirdPartyApiService thirdPartyApiService; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("分页查询秘钥") | |||
| @GetMapping("/page") | |||
| public R<PageInfo<WxThirdPartyApi>> pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | |||
| return R.ok(thirdPartyApiService.pageThirdPartyApi(thirdPartyApi, pageNum, pageSize)); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("单个查询秘钥") | |||
| @GetMapping("/get") | |||
| public R<WxThirdPartyApi> getThirdPartyApi(Long id) { | |||
| if (id == null) { | |||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return R.ok(thirdPartyApiService.getThirdPartyApi(id)); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("修改秘钥状态") | |||
| @PostMapping("/updateStatus") | |||
| public R<Void> updateThirdPartyApiStatus(@RequestBody UpdateThirdPartyApiStatusDTO dto) { | |||
| thirdPartyApiService.updateThirdPartyApiStatus(dto); | |||
| return R.ok(); | |||
| } | |||
| } | |||
| @@ -2,9 +2,11 @@ package com.iformall.controller.sys; | |||
| import com.google.code.kaptcha.Constants; | |||
| import com.google.code.kaptcha.Producer; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| @@ -75,6 +77,7 @@ public class HomeController extends BaseController { | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("验证码") | |||
| @GetMapping("/captcha.jpg") | |||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | |||
| @@ -87,30 +90,44 @@ public class HomeController extends BaseController { | |||
| //生成图片验证码 | |||
| BufferedImage image = producer.createImage(text); | |||
| //保存到shiro session | |||
| ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||
| // ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||
| String key = Constant.captchaPrev + ":" + getIpAddr(); | |||
| RedisCacheUtils.cache(redisTemplate, key, text, 60); | |||
| logger.info("验证码接口-生成的验证码:{}", text); | |||
| ServletOutputStream out = response.getOutputStream(); | |||
| ImageIO.write(image, "jpg", out); | |||
| IOUtils.closeQuietly(out); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("登录") | |||
| @PostMapping("/doLogin") | |||
| public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] HomeController::doLogin"); | |||
| try { | |||
| String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||
| if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||
| } | |||
| } catch (MallinkException e) { | |||
| logger.error("验证码" + e.getMessage()); | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | |||
| // try { | |||
| // String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||
| // logger.info("登录接口-验证码:{}", user.getCaptcha()); | |||
| // logger.info("登录接口-生成的验证码:{}", kaptcha); | |||
| // if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||
| // return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||
| // } | |||
| // } catch (MallinkException e) { | |||
| // logger.error("验证码" + e.getMessage()); | |||
| // return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | |||
| // } | |||
| String key = Constant.captchaPrev + ":" + getIpAddr(); | |||
| String code = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||
| } | |||
| if (!code.equals(user.getCaptcha())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||
| } | |||
| if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | |||
| // throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| // check user | |||
| @@ -1,10 +1,12 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| @@ -43,13 +45,12 @@ public class MallRoleController extends BaseController { | |||
| @Autowired | |||
| private MallUserRoleService mallUserRoleService; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("角色列表") | |||
| @GetMapping("list") | |||
| //@RequiresPermissions("sys:role:list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "用户管理-role列表") | |||
| public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | |||
| sysRole.updateTenantInfo(getTenantInfo()); | |||
| @@ -97,7 +98,7 @@ public class MallRoleController extends BaseController { | |||
| return new ResultData(role); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("角色保存") | |||
| @PostMapping("saveOrUpdate") | |||
| //@RequiresPermissions("sys:role:save") | |||
| @@ -128,6 +129,7 @@ public class MallRoleController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("角色删除") | |||
| @PostMapping("/del") | |||
| //@RequiresPermissions("sys:role:del") | |||
| @@ -1,10 +1,12 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| @@ -60,6 +62,7 @@ public class MallUserInfoController extends BaseController { | |||
| @Autowired | |||
| WxMsgValidationcodeService wxMsgValidationcodeService; | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation(value = "用户分页接口", response = String.class) | |||
| @GetMapping("lists") | |||
| //@RequiresPermissions("sys:user:list") | |||
| @@ -110,6 +113,7 @@ public class MallUserInfoController extends BaseController { | |||
| return new ResultData(user); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation(value = "创建用户接口", response = String.class) | |||
| @PostMapping("add") | |||
| //@RequiresPermissions("sys:user:add") | |||
| @@ -147,6 +151,7 @@ public class MallUserInfoController extends BaseController { | |||
| return new ResultData(userInfo); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation(value = "修改用户接口", response = String.class) | |||
| @PostMapping("update") | |||
| //@RequiresPermissions("sys:user:update") | |||
| @@ -225,6 +230,7 @@ public class MallUserInfoController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation(value = "删除用户接口", response = String.class) | |||
| @PostMapping("/del") | |||
| //@RequiresPermissions("sys:user:del") | |||
| @@ -320,6 +326,7 @@ public class MallUserInfoController extends BaseController { | |||
| return new ResultData(menu); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation(value = "用户密码发送验证码") | |||
| @GetMapping("sendvalidationcode") | |||
| @ApiImplicitParams({ | |||
| @@ -353,6 +360,7 @@ public class MallUserInfoController extends BaseController { | |||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation(value = "修改密码", notes = "{\"userName\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") | |||
| @PostMapping("/updatepwd") | |||
| @SystemControllerLog(description = "用户管理-修改密码") | |||
| @@ -1,9 +1,11 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallPermission; | |||
| import com.iformall.domain.po.MallRole; | |||
| @@ -65,6 +67,7 @@ public class SysMenuController extends BaseController { | |||
| return new ResultData(map); | |||
| } | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("所有菜单列表") | |||
| @GetMapping("list") | |||
| //@RequiresPermissions("sys:menu:list") | |||
| @@ -46,11 +46,6 @@ public class MyShiroRealm extends AuthorizingRealm { | |||
| if(user == null) { | |||
| throw new UnknownAccountException(ErrorCode.USER_IS_EMPTY.getMessage()); | |||
| } | |||
| // 租户1为预留系统管理端 | |||
| // if(user.getTenantId().equals("1")) { | |||
| // // 只支持租户为1的用户 | |||
| // throw new UnknownAccountException("租户不支持"); | |||
| // } | |||
| if(user.getStatus()==null || | |||
| !EnumMallUserStatus.VALID.getCode().equals(user.getStatus())) {//用户被禁用 | |||
| @@ -67,16 +62,6 @@ public class MyShiroRealm extends AuthorizingRealm { | |||
| session.setAttribute(UserSession.userInfo, user); | |||
| session.setAttribute(UserSession.userId, user.getId()); | |||
| session.setAttribute(UserSession.tenantId, user.getTenantId()); | |||
| if (StringUtils.isNotBlank(user.getParentTenantId())) { | |||
| session.setAttribute(UserSession.parentTenantId, user.getParentTenantId()); | |||
| }else{ | |||
| session.setAttribute(UserSession.parentTenantId, null); | |||
| // String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId); | |||
| // if(StringUtils.isNotBlank(parentTenantId)){ | |||
| // session.removeAttribute(UserSession.parentTenantId); | |||
| // } | |||
| } | |||
| return authenticationInfo; | |||
| } | |||
| @@ -200,4 +200,27 @@ ueditor: | |||
| logging: | |||
| level: | |||
| com.iformall: debug | |||
| path: ./logs/admin | |||
| path: ./logs/admin | |||
| suimang: | |||
| oral_broadcasting: xxx | |||
| video_tts: | |||
| photo_speak: xxx | |||
| photo_speak_hy: xxx | |||
| digital_avatar: xxx | |||
| digital_avatar_hy: xxx | |||
| callbackUrl: xxx | |||
| swagger: | |||
| base-package: com.iformall.controller | |||
| title: 遂芒_metavatar_接口文档 | |||
| description: 前后端联调 | |||
| version: 1.0 | |||
| license: Apache | |||
| license-url: https://mtest.metavatar.cc/ | |||
| terms-of-service-url: https://mtest.metavatar.cc/ | |||
| host: localhost:8888 | |||
| contact: | |||
| name: 张三 | |||
| url: https://mtest.metavatar.cc/ | |||
| email: zhangsan@163.com | |||
| @@ -156,4 +156,13 @@ ueditor: | |||
| logging: | |||
| level: | |||
| com.iformall.mapper: debug | |||
| path: ./logs/admin | |||
| path: ./logs/admin | |||
| suimang: | |||
| oral_broadcasting: xxx | |||
| video_tts: | |||
| photo_speak: xxx | |||
| photo_speak_hy: xxx | |||
| digital_avatar: xxx | |||
| digital_avatar_hy: xxx | |||
| callbackUrl: xxx | |||
| @@ -1,7 +1,7 @@ | |||
| server: | |||
| port: 9500 | |||
| servlet: | |||
| context-path: / | |||
| context-path: /A | |||
| spring: | |||
| application: | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall; | |||
| import com.iformall.annotation.BaseEnableSwagger; | |||
| import org.mybatis.spring.annotation.MapperScan; | |||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| @@ -15,6 +16,7 @@ import org.springframework.scheduling.annotation.EnableAsync; | |||
| * @author chenkx | |||
| * @date 2017-12-26 | |||
| */ | |||
| @BaseEnableSwagger | |||
| @SpringBootApplication | |||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||
| @EnableEncryptableProperties | |||
| @@ -1,61 +1,61 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import springfox.documentation.builders.ApiInfoBuilder; | |||
| import springfox.documentation.builders.ParameterBuilder; | |||
| import springfox.documentation.builders.PathSelectors; | |||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||
| import springfox.documentation.schema.ModelRef; | |||
| import springfox.documentation.service.ApiInfo; | |||
| import springfox.documentation.service.Parameter; | |||
| import springfox.documentation.spi.DocumentationType; | |||
| import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| import springfox.documentation.spring.web.plugins.Docket; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| import javax.servlet.ServletContext; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| //参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| @Configuration | |||
| @EnableSwagger2 | |||
| public class Swagger2Config { | |||
| @Autowired | |||
| private ServletContext servletContext; | |||
| @Bean | |||
| public Docket createRestApi() { | |||
| ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| List<Parameter> pars = new ArrayList<Parameter>(); | |||
| //增加一个request的header参数 | |||
| tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| pars.add(tokenPar.build()); | |||
| return new Docket(DocumentationType.SWAGGER_2) | |||
| .apiInfo(apiInfo()) | |||
| .select() | |||
| .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| .paths(PathSelectors.any()) | |||
| .build() | |||
| .globalOperationParameters(pars) | |||
| .pathProvider(new RelativePathProvider(servletContext) { | |||
| @Override | |||
| public String getApplicationBasePath() { | |||
| return "/api"; | |||
| } | |||
| }); | |||
| } | |||
| private ApiInfo apiInfo() { | |||
| return new ApiInfoBuilder() | |||
| .title("c端 api") | |||
| .description("c api") | |||
| .termsOfServiceUrl("http://localhost:7000") | |||
| .version("2.0") | |||
| .build(); | |||
| } | |||
| } | |||
| //package com.iformall.config; | |||
| // | |||
| //import org.springframework.beans.factory.annotation.Autowired; | |||
| //import org.springframework.context.annotation.Bean; | |||
| //import org.springframework.context.annotation.Configuration; | |||
| //import springfox.documentation.builders.ApiInfoBuilder; | |||
| //import springfox.documentation.builders.ParameterBuilder; | |||
| //import springfox.documentation.builders.PathSelectors; | |||
| //import springfox.documentation.builders.RequestHandlerSelectors; | |||
| //import springfox.documentation.schema.ModelRef; | |||
| //import springfox.documentation.service.ApiInfo; | |||
| //import springfox.documentation.service.Parameter; | |||
| //import springfox.documentation.spi.DocumentationType; | |||
| //import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| //import springfox.documentation.spring.web.plugins.Docket; | |||
| //import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| // | |||
| //import javax.servlet.ServletContext; | |||
| //import java.util.ArrayList; | |||
| //import java.util.List; | |||
| // | |||
| ////参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| //@Configuration | |||
| //@EnableSwagger2 | |||
| //public class Swagger2Config { | |||
| // | |||
| // @Autowired | |||
| // private ServletContext servletContext; | |||
| // | |||
| // @Bean | |||
| // public Docket createRestApi() { | |||
| // ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| // List<Parameter> pars = new ArrayList<Parameter>(); | |||
| // //增加一个request的header参数 | |||
| // tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| // pars.add(tokenPar.build()); | |||
| // return new Docket(DocumentationType.SWAGGER_2) | |||
| // .apiInfo(apiInfo()) | |||
| // .select() | |||
| // .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| // .paths(PathSelectors.any()) | |||
| // .build() | |||
| // .globalOperationParameters(pars) | |||
| // .pathProvider(new RelativePathProvider(servletContext) { | |||
| // @Override | |||
| // public String getApplicationBasePath() { | |||
| // return "/api"; | |||
| // } | |||
| // }); | |||
| // } | |||
| // | |||
| // private ApiInfo apiInfo() { | |||
| // return new ApiInfoBuilder() | |||
| // .title("c端 api") | |||
| // .description("c api") | |||
| // .termsOfServiceUrl("http://localhost:7000") | |||
| // .version("2.0") | |||
| // .build(); | |||
| // } | |||
| // | |||
| //} | |||
| @@ -54,7 +54,9 @@ public class WebMvcConfig implements WebMvcConfigurer { | |||
| @Override | |||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||
| registry.addResourceHandler("swagger-ui.html") | |||
| // registry.addResourceHandler("swagger-ui.html") | |||
| // .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("doc.html") | |||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("/webjars/**") | |||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||
| @@ -0,0 +1,32 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.common.R; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.domain.po.sm.ApiGuide; | |||
| import com.iformall.service.sm.ApiGuideService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @RestController | |||
| @RequestMapping("/api/apiGuide") | |||
| @Api(tags = "api指南接口") | |||
| public class ApiGuideController { | |||
| @Autowired | |||
| private ApiGuideService apiGuideService; | |||
| @AuthIgnore | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("单个查询api指南") | |||
| @GetMapping("/getAvailableApiGuide") | |||
| public R<ApiGuide> getAvailableApiGuide() { | |||
| return R.ok(apiGuideService.getAvailableApiGuide()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,58 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.annotation.ApiVersion; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.R; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.constant.SwaggerConstant; | |||
| import com.iformall.domain.po.sm.ApiMenu; | |||
| import com.iformall.domain.vo.sm.ApiMenuVO; | |||
| import com.iformall.domain.vo.sm.ListApiSubmenuVO; | |||
| import com.iformall.exception.BizException; | |||
| import com.iformall.service.sm.ApiMenuService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("/api/apiMenu") | |||
| @Api(tags = "api菜单接口") | |||
| public class ApiMenuController { | |||
| @Autowired | |||
| private ApiMenuService apiMenuService; | |||
| @AuthIgnore | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("全查询api菜单") | |||
| @GetMapping("/list") | |||
| public R<List<ApiMenu>> listApiMenu() { | |||
| return R.ok(apiMenuService.listMenu()); | |||
| } | |||
| @AuthIgnore | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("查询某个api菜单所有子菜单") | |||
| @GetMapping("/listSubmenu") | |||
| public R<List<ListApiSubmenuVO>> listApiSubmenu(Long id) { | |||
| if (id == null) { | |||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return R.ok(apiMenuService.listApiSubmenu(id)); | |||
| } | |||
| @AuthIgnore | |||
| @ApiVersion(group = SwaggerConstant.V_1_0_0) | |||
| @ApiOperation("单个查询菜单详情") | |||
| @GetMapping("/get") | |||
| public R<ApiMenuVO> getApiMenu(Long id) { | |||
| if (id == null) { | |||
| throw new BizException(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| return R.ok(apiMenuService.getApiMenu(id)); | |||
| } | |||
| } | |||
| @@ -10,6 +10,7 @@ import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.enums.EnumProductOrderPayVendor; | |||
| import com.iformall.interceptor.BodyReaderHttpServletRequestWrapper; | |||
| import com.iformall.service.ProductOrderPayService; | |||
| import com.iformall.service.ProductOrderService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| @@ -18,6 +19,7 @@ import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.service.pay.service.pay.PayAdapterService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.jdom2.JDOMException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -26,8 +28,12 @@ import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.BufferedReader; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.InputStreamReader; | |||
| import java.util.HashMap; | |||
| import java.util.Iterator; | |||
| import java.util.Map; | |||
| @@ -52,7 +58,8 @@ public class CallbackPayController extends BaseController { | |||
| @AuthIgnore | |||
| @ApiOperation("支付回调") | |||
| @PostMapping(value = "{projectType}/pay/v3") | |||
| public void _payV3Notify(@PathVariable Integer projectType,@RequestBody Map<String, Object> paranMap, HttpServletResponse response) { | |||
| public void _payV3Notify(@PathVariable Integer projectType, @RequestBody Map<String, Object> paranMap, | |||
| HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] CallbackPayController::_payV3Notify"); | |||
| logger.info("微信支付回调结果通知{}"+JSONObject.toJSONString(paranMap)); | |||
| /** | |||
| @@ -107,8 +114,9 @@ public class CallbackPayController extends BaseController { | |||
| @AuthIgnore | |||
| @ApiOperation("支付回调") | |||
| @PostMapping(value = "/ttNotify") | |||
| public Map<String,Object> _ttNotify(@RequestBody Map<String, Object> paranMap, HttpServletRequest request, HttpServletResponse response) { | |||
| @PostMapping(value = "{projectType}/ttNotify") | |||
| public Map<String,Object> _ttNotify(@PathVariable Integer projectType, @RequestBody Map<String, Object> paranMap, | |||
| HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] CallbackPayController::_ttNotify"); | |||
| Map<String,Object> resultMap = new HashMap<>(); | |||
| logger.info("抖音支付回调结果通知{}"+JSONObject.toJSONString(paranMap)); | |||
| @@ -120,8 +128,9 @@ public class CallbackPayController extends BaseController { | |||
| String type = (String) paranMap.get("type"); | |||
| Map<String, Object> pMap = JSONObject.parseObject(msg, Map.class); | |||
| String appid = (String) pMap.get("appid"); | |||
| WxAppinfo appInfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||
| // String appid = (String) pMap.get("appid"); | |||
| // WxAppinfo appInfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||
| WxAppinfo appInfo = wxAppinfoService.getProjectCAppInfoFromRedis(projectType, EnumAppPlat.TOUTIAO.getCode()); | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||
| if("payment".equals(type)){ | |||
| String out_order_no = (String)pMap.get("cp_orderno"); | |||
| @@ -145,40 +154,59 @@ public class CallbackPayController extends BaseController { | |||
| @AuthIgnore | |||
| @ApiOperation("支付回调") | |||
| @PostMapping(value = "/aliNotify") | |||
| public Map<String,Object> _aliNotify(@RequestBody Map<String, Object> paranMap, HttpServletRequest request, HttpServletResponse response) { | |||
| @PostMapping(value = "{projectType}/aliNotify") | |||
| public String _aliNotify(@PathVariable Integer projectType, | |||
| HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] CallbackPayController::_aliNotify"); | |||
| String body = ((BodyReaderHttpServletRequestWrapper) request).getBody(); | |||
| logger.info("ali支付回调结果通知 body{}"+body); | |||
| Map<String,Object> resultMap = new HashMap<>(); | |||
| logger.info("ali支付回调结果通知{}"+JSONObject.toJSONString(paranMap)); | |||
| /** | |||
| * ----效验数据来源合法 | |||
| */ | |||
| try{ | |||
| // String msg = (String) paranMap.get("msg"); | |||
| // String type = (String) paranMap.get("type"); | |||
| // | |||
| // Map<String, Object> pMap = JSONObject.parseObject(msg, Map.class); | |||
| // String appid = (String) pMap.get("appid"); | |||
| // WxAppinfo appInfo = wxAppinfoService.getOnlyByAppIdFromRedis(appid); | |||
| // WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||
| // if("payment".equals(type)){ | |||
| // String out_order_no = (String)pMap.get("cp_orderno"); | |||
| // | |||
| // EnumProductOrderPayVendor payVendorEnum = EnumProductOrderPayVendor.PAY_WAY_TT; | |||
| // ProductOrderPay orderPay = productOrderPayService.getByOrder(Long.parseLong(out_order_no), payVendorEnum); | |||
| // | |||
| // PayAdapterService payAdapterService = payServiceFactory.getPayAdapterService(payVendorEnum.getCode()); | |||
| // productOrderPayService.handleProductOrderByQuery(appInfo,payAccount,orderPay,payAdapterService); | |||
| // | |||
| // resultMap.put("err_no",0); | |||
| // resultMap.put("err_tips","success"); | |||
| // } | |||
| Map<String, String> paranMap = handBody(body); | |||
| logger.info("ali支付回调结果通知 paranMap{}"+JSONObject.toJSONString(paranMap)); | |||
| // String app_id = paranMap.get("app_id"); | |||
| // WxAppinfo appInfo = wxAppinfoService.getOnlyByAppIdFromRedis(app_id); | |||
| WxAppinfo appInfo = wxAppinfoService.getProjectCAppInfoFromRedis(projectType, EnumAppPlat.ALI.getCode()); | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||
| String out_trade_no = paranMap.get("out_trade_no"); | |||
| String trade_status = paranMap.get("trade_status"); | |||
| if("TRADE_SUCCESS".equals(trade_status)){ | |||
| EnumProductOrderPayVendor payVendorEnum = EnumProductOrderPayVendor.PAY_WAY_ALIPAY_WAP; | |||
| ProductOrderPay orderPay = productOrderPayService.getByOrder(Long.parseLong(out_trade_no), payVendorEnum); | |||
| PayAdapterService payAdapterService = payServiceFactory.getPayAdapterService(payVendorEnum.getCode()); | |||
| productOrderPayService.handleProductOrderByQuery(appInfo,payAccount,orderPay,payAdapterService); | |||
| } | |||
| return "success"; | |||
| }catch(Exception e){ | |||
| logger.error("抖音支付回调处理异常"+e); | |||
| resultMap.put("err_no",ErrorCode.SYS_SERVER_ERROR.getCode()); | |||
| resultMap.put("err_tips","抖音支付回调处理异常"); | |||
| logger.error("ali支付回调处理异常"+e); | |||
| } | |||
| return resultMap; | |||
| return "fail"; | |||
| } | |||
| private Map<String,String> handBody(String body){ | |||
| Map<String,String> map = new HashMap<>(); | |||
| if(StringUtils.isNotBlank(body)){ | |||
| String[] key_value = body.split("&"); | |||
| if(key_value.length > 0){ | |||
| for (String kv: key_value) { | |||
| String[] split = kv.split("="); | |||
| map.put(split[0],split[1]); | |||
| } | |||
| } | |||
| } | |||
| return map; | |||
| } | |||
| } | |||
| @@ -89,22 +89,17 @@ public class MiniAppUserController extends BaseController { | |||
| public ResultData login(@RequestBody Map<String, String> map) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] MiniAppUserController::login"); | |||
| logger.info("login >>>>>>>>>>>>>>>>>"+map.toString()); | |||
| Map resultMap = new HashMap(); | |||
| String project = map.get("projectType"); | |||
| String appId = map.get("appId"); | |||
| String code = map.get("code"); | |||
| //登录凭证不能为空 | |||
| if (StringUtils.isBlank(appId)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "code不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||
| WxAppinfo wxAppinfo = getAppInfo(appId,project); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| @@ -176,21 +171,19 @@ public class MiniAppUserController extends BaseController { | |||
| public ResultData loginPhone(@RequestBody Map<String, String> map) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] MiniAppUserController::loginPhone"); | |||
| logger.info("loginPhone >>>>>>>>>>>>>>>>>"+map.toString()); | |||
| String project = map.get("projectType"); | |||
| String appId = map.get("appId"); | |||
| String openId = map.get("openId"); | |||
| String encryptedData = map.get("encryptedData"); | |||
| String iv = map.get("iv"); | |||
| if(StringUtils.isBlank(appId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||
| } | |||
| if(StringUtils.isBlank(openId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "openId 不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||
| WxAppinfo wxAppinfo = getAppInfo(appId,project); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| @@ -252,23 +245,20 @@ public class MiniAppUserController extends BaseController { | |||
| public ResultData loginPhoneCode(@RequestBody Map<String, String> map, HttpServletResponse response) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] MiniAppUserController::loginPhoneCode"); | |||
| logger.info("loginPhoneCode >>>>>>>>>>>>>>>>>"+map.toString()); | |||
| // String phone,String code,String pwd | |||
| String project = map.get("projectType"); | |||
| String appId = map.get("appId"); | |||
| String openId = map.get("openId"); | |||
| String phone = map.get("phone"); | |||
| String code = map.get("code"); | |||
| if(StringUtils.isBlank(appId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||
| } | |||
| if(StringUtils.isBlank(openId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "openId 不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||
| WxAppinfo wxAppinfo = getAppInfo(appId,project); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| @@ -334,15 +324,13 @@ public class MiniAppUserController extends BaseController { | |||
| @PostMapping("/getUserQrcode") | |||
| @ApiOperation(value = "获取二维码", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||
| public ResultData getUserQrcode(@RequestBody Map<String, String> map) { | |||
| logger.info(map.toString()); | |||
| logger.info("getUserQrcode >>>>>>>>>>>>>>>>>"+map.toString()); | |||
| String project = map.get("projectType"); | |||
| String appId = map.get("appId"); | |||
| String img = map.get("img"); | |||
| if(StringUtils.isBlank(appId)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId 不能为空"); | |||
| } | |||
| WxAppinfo wxAppinfo = wxAppinfoService.getOnlyByAppIdFromRedis(appId); | |||
| WxAppinfo wxAppinfo = getAppInfo(appId,project); | |||
| if(wxAppinfo == null){ | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| @@ -369,4 +357,21 @@ public class MiniAppUserController extends BaseController { | |||
| } | |||
| } | |||
| private WxAppinfo getAppInfo(String appId,String project){ | |||
| if (StringUtils.isBlank(appId)) { | |||
| return null; | |||
| } | |||
| Integer projectType = null; | |||
| if(StringUtils.isNotBlank(project)){ | |||
| try{ | |||
| projectType = Integer.parseInt(project); | |||
| }catch(Exception e){} | |||
| } | |||
| //兼容处理 | |||
| if(projectType == null){ | |||
| projectType = EnumProject.PROJECT_5.getCode(); | |||
| } | |||
| return wxAppinfoService.getProjectCAppInfo(appId,projectType); | |||
| } | |||
| } | |||
| @@ -1,31 +1,15 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.OrderComposeSaveDto; | |||
| import com.iformall.domain.dto.OrderSaveDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.sm.PersonPhoto; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.pay.PayServiceFactory; | |||
| import com.iformall.service.pay.entity.PayExtraParam; | |||
| import com.iformall.service.pay.service.pay.PayAdapterService; | |||
| import com.iformall.sm.AiDigitalAvatarHelper; | |||
| import com.iformall.sm.ShareImgParam; | |||
| import com.iformall.sm.ShareImgResult; | |||
| import com.iformall.utils.Base64Util; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -33,12 +17,6 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("/api/productOrder") | |||
| @@ -85,43 +85,44 @@ public class UserLiveController extends BaseController { | |||
| @PostMapping("/login") | |||
| @ApiOperation(value = "用户登录", notes = "{\"username\":\"string\",\"password\":\"string\",\"code\":\"string\",\"status\":\"int\"}") | |||
| public Map<String, Object> login(@RequestBody Map<String, String> map, HttpServletResponse response) { | |||
| Map<String, Object> wxCLiveLoginVos = new HashMap<>(); | |||
| String ipAddr = getIpAddr(); | |||
| logger.debug("[" + ipAddr + "] WxUserGrantController::login"); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| String code = map.get("code"); | |||
| String phone = map.get("username"); | |||
| String password = map.get("password"); | |||
| if (StringUtils.isBlank(phone) || StringUtils.isBlank(password)) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.SYS_PARAMETER_ERROR.getCode()); | |||
| status.put("message", "手机号或密码为空"); | |||
| wxCLiveLoginVos.put("status", status); | |||
| return wxCLiveLoginVos; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); | |||
| if (basicInfo == null) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.USER_IS_EMPTY); | |||
| status.put("message", "用户不存在"); | |||
| wxCLiveLoginVos.put("status", status); | |||
| return wxCLiveLoginVos; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| String encryptPassword = new PasswordHelper().encryptPassword(password); | |||
| if (!encryptPassword.equals(basicInfo.getPassword())) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.USER_PASSWD_ERR.getCode()); | |||
| status.put("message", "手机号或密码错误"); | |||
| wxCLiveLoginVos.put("status", status); | |||
| return wxCLiveLoginVos; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| int statu = Integer.parseInt(map.get("status")); | |||
| if (statu == 0) { | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); | |||
| if (basicLiveInfo.getCode() != null && !map.get("code").equals(basicLiveInfo.getCode())) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||
| status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | |||
| status.put("message", "用户已在其他设备登录"); | |||
| wxCLiveLoginVos.put("status", status); | |||
| return wxCLiveLoginVos; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| if (basicLiveInfo.getCode() == null) { | |||
| wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), map.get("code")); | |||
| @@ -130,37 +131,28 @@ public class UserLiveController extends BaseController { | |||
| if (statu == -1) { | |||
| wxCLiveUserBasicInfoService.updateCode(basicInfo.getId(), null); | |||
| basicInfo.setStatus(-2); | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.USER_CANCEL_MCODE.getCode()); | |||
| status.put("message", "设备已注销"); | |||
| wxCLiveLoginVos.put("status", status); | |||
| return wxCLiveLoginVos; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| wxCUserBasicInfoService.handleLoginUser(basicInfo); | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(basicInfo.getId()); | |||
| WxCLiveLoginVo wxCLiveLoginVo = new WxCLiveLoginVo(); | |||
| wxCLiveLoginVo.setCode(map.get("code")); | |||
| wxCLiveLoginVo.setUsername(map.get("username")); | |||
| Map<String, Object> info = new HashMap(); | |||
| Map<String, Object> data = new HashMap(); | |||
| Map<Object, Object> status = new HashMap<>(); | |||
| status.put("code", 1000); | |||
| status.put("message", "success"); | |||
| data.put("token", basicInfo.getToken()); | |||
| data.put("username",basicInfo.getPhone()); | |||
| data.put("status", 0); | |||
| data.put("version", basicLiveInfo.getVersion()); | |||
| data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | |||
| data.put("expire_time", basicLiveInfo.getExpireTime().getTime() / 1000); | |||
| info.put("log_id", basicInfo.getId()); | |||
| info.put("server_type", "user login"); | |||
| info.put("username", basicInfo.getPhone()); | |||
| wxCLiveLoginVos.put("data", data); | |||
| wxCLiveLoginVos.put("info", info); | |||
| wxCLiveLoginVo.setData(data); | |||
| wxCLiveLoginVo.setInfo(info); | |||
| wxCLiveLoginVos.put("status", status); | |||
| System.out.println("wxCLiveLoginVo.getToken() = " + wxCLiveLoginVo.getToken()); | |||
| return wxCLiveLoginVos; | |||
| data.put("token", basicInfo.getToken()); | |||
| resultMap.put("data", data); | |||
| status.put("code", 1000); | |||
| status.put("message", "success"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| /** | |||
| @@ -170,24 +162,30 @@ public class UserLiveController extends BaseController { | |||
| @PostMapping("/avatarList") | |||
| @ApiOperation(value = "视频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") | |||
| public Map<String, Object> avatarList(@RequestBody Map<String, String> params) throws Exception { | |||
| Map<String, Object> avatarVos = new HashMap<>(); | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] WxUserGrantController::getAvatarList"); | |||
| Long id = getMemberId(); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| String code = params.get("code"); | |||
| Long userId = getMemberId(); | |||
| //鉴权 | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); | |||
| if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(userId); | |||
| if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||
| status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | |||
| status.put("message", "用户已在其他设备登录"); | |||
| avatarVos.put("status", status); | |||
| return avatarVos; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| Map<Object, Object> status = new HashMap<>(); | |||
| Map<String, Object> data = wxCVideoService.getById(userId); | |||
| resultMap.put("data", data); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| avatarVos.put("status", status); | |||
| return wxCVideoService.getById(id); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| @@ -198,77 +196,134 @@ public class UserLiveController extends BaseController { | |||
| @PostMapping("/audioList") | |||
| @ApiOperation(value = "音频模板列表", notes = "{\"username\",\"string\",\"code\",\"string\"}") | |||
| public Map<String, Object> audioList(@RequestBody Map<String, String> params) { | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] WxUserGrantController::getAudioList"); | |||
| Long id = getMemberId(); | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); | |||
| if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| String code = params.get("code"); | |||
| Long userId = getMemberId(); | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(userId); | |||
| if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||
| status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | |||
| status.put("message", "用户已在其他设备登录"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| return wxCVoiceService.getById(id,null); | |||
| Map<String, Object> data = wxCVoiceService.getById(userId); | |||
| resultMap.put("data", data); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| /** | |||
| * 资源权限查询 | |||
| */ | |||
| @ApiOperation(value = "资源权限查询", notes = "{\"username\",\"string\",\"code\",\"string\",\"type\",\"int\",\"resource_id\",\"long\"}") | |||
| @PostMapping("/author") | |||
| public Map<String, Object> getAuthor(@RequestBody Map<String, String> params) { | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] WxUserGrantController::getAuthor"); | |||
| Long id = getMemberId(); | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(id); | |||
| if (basicLiveInfo.getCode() != null && !params.get("code").equals(basicLiveInfo.getCode())) { | |||
| HashMap<Object, Object> status = new HashMap<>(); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| String code = params.get("code"); | |||
| Integer type = Integer.parseInt(params.get("type")); | |||
| Long resourceId = Long.valueOf(params.get("resource_id")); | |||
| if(type == null){ | |||
| status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| status.put("message", "type 为空"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| if(resourceId == null){ | |||
| status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| status.put("message", "资源ID 为空"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| Long userId = getMemberId(); | |||
| WxCUserBasicInfo basicLiveInfo = wxCLiveUserBasicInfoService.getById(userId); | |||
| if (basicLiveInfo.getCode() != null && !basicLiveInfo.getCode().equals(code)) { | |||
| status.put("code", ErrorCode.USER_ALREADY_LOGIN.getCode()); | |||
| status.put("message", "用户已在其他设备登录"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| String code = params.get("code"); | |||
| Integer type = Integer.parseInt(params.get("type")); | |||
| Long resourceId = Long.valueOf(params.get("resource_id")); | |||
| return wxCUserAuthorityService.getAuthor(id, code, type, resourceId); | |||
| Map<String, Object> data = wxCUserAuthorityService.getAuthor(userId, code, type, resourceId); | |||
| if(data != null){ | |||
| resultMap.put("data", data); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| status.put("code", ErrorCode.SYS_NULLPOINTER_ERROR.getCode()); | |||
| status.put("msg", "未查询到资源权限"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| @ApiOperation(value = "tts", notes = "{\"username\",\"string\",\"gen_txt\",\"string\",\"voice_id\",\"string\",\"voice_style\",\"string\",\"speed\",\"int\"}") | |||
| @PostMapping("/audiotts") | |||
| public Map<String, Object> voicePreview(@RequestBody Map<String, String> params) { | |||
| logger.debug("[" + getIpAddr() + "] UserLiveController::voicePreview"); | |||
| Long id = getMemberId(); | |||
| AiPreviewParam param = new AiPreviewParam(); | |||
| if (params.get("voice_id") == null) { | |||
| Map<String, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| String voice_id = params.get("voice_id"); | |||
| String voiceStyle = params.get("voice_style"); | |||
| if (StringUtils.isBlank(voice_id)) { | |||
| status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| status.put("msg", "音色ID不能为空"); | |||
| return status; | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| if (StringUtils.isBlank(params.get("gen_txt"))) { | |||
| Map<String, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); | |||
| status.put("msg", "需要生成的文字不能为空"); | |||
| return status; | |||
| Long voiceId = null; | |||
| try{ | |||
| voiceId = Long.parseLong(voice_id); | |||
| }catch(Exception e){ | |||
| status.put("code", ErrorCode.SYS_PARAMETER_ERROR.getCode()); | |||
| status.put("msg", "音色ID参数异常"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| String text = params.get("gen_txt"); | |||
| if (StringUtils.isBlank(text)) { | |||
| resultMap.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| resultMap.put("msg", "需要生成的文字不能为空"); | |||
| return resultMap; | |||
| } | |||
| if (Integer.parseInt(params.get("speed")) == -1) { | |||
| param.setSpeed(0); | |||
| String speedStr = params.get("speed"); | |||
| Integer speed = null; | |||
| try{ | |||
| speed = Integer.parseInt(speedStr); | |||
| }catch(Exception e){} | |||
| Map<String, Object> data = wxCVoiceService.voicePreview(voiceId,voiceStyle,text,speed); | |||
| if(data != null){ | |||
| resultMap.put("data", data); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| param.setSpeed(Integer.parseInt(params.get("speed"))); | |||
| param.setVoice_id(params.get("voice_id")); | |||
| param.setVoice_style(params.get("voice_style")); | |||
| param.setGen_txt(params.get("gen_txt")); | |||
| Map<String, Object> resultMap = wxCVoiceService.voicePreview(param); | |||
| Map<String, Object> info = new HashMap<>(); | |||
| info.put("log_id", id); | |||
| info.put("server_type", "audio tts"); | |||
| resultMap.put("info", info); | |||
| status.put("code", ErrorCode.SYS_PARAMETER_NOT_NULL.getCode()); | |||
| status.put("msg", "获取tts 异常"); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| } | |||
| @@ -330,7 +385,6 @@ public class UserLiveController extends BaseController { | |||
| public ResultData chooseType(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] MouldPatchController::chooseType"); | |||
| List<VoiceInfo> voiceInfos = wxCVoiceService.chooseType(id); | |||
| System.out.println("voiceInfos = " + voiceInfos); | |||
| return new ResultData(wxCVoiceService.chooseType(id)); | |||
| return new ResultData(voiceInfos); | |||
| } | |||
| } | |||
| @@ -1,8 +1,7 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.neuver.GetLanguageDTO; | |||
| import com.iformall.domain.dto.sm.GetLanguageDTO; | |||
| import com.iformall.service.sm.VoiceLanguageService; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.google.code.kaptcha.Constants; | |||
| import com.google.code.kaptcha.Producer; | |||
| import com.iformall.annotation.AuthIgnore; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| @@ -42,6 +43,7 @@ import javax.imageio.ImageIO; | |||
| import javax.servlet.ServletOutputStream; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import javax.servlet.http.HttpSession; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.IOException; | |||
| import java.util.Date; | |||
| @@ -115,7 +117,7 @@ public class WxUserGrantController extends BaseController { | |||
| @AuthIgnore | |||
| @ApiOperation("验证码") | |||
| @GetMapping("/captcha.jpg") | |||
| public void captcha(HttpServletResponse response) { | |||
| public void captcha(HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxUserGrantController::captcha"); | |||
| response.setHeader("Cache-Control", "no-store, no-cache"); | |||
| response.setContentType("image/jpeg"); | |||
| @@ -126,9 +128,11 @@ public class WxUserGrantController extends BaseController { | |||
| BufferedImage image = producer.createImage(text); | |||
| //保存到redis | |||
| String ipAddr = getIpAddr(); | |||
| String key = Constant.captchaPrev + ":" + ipAddr; | |||
| RedisCacheUtils.cache(redisTemplate, key, text, 60); | |||
| // String ipAddr = getIpAddr(); | |||
| // String key = Constant.captchaPrev + ":" + ipAddr; | |||
| // RedisCacheUtils.cache(redisTemplate, key, text, 60); | |||
| HttpSession session = request.getSession(); | |||
| session.setAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||
| ServletOutputStream out = null; | |||
| try { | |||
| @@ -152,7 +156,7 @@ public class WxUserGrantController extends BaseController { | |||
| @AuthIgnore | |||
| @PostMapping("/login") | |||
| @ApiOperation(value = "用户登录", notes = "{\"phone\":\"string\",\"password\":\"string\",\"code\":\"string\"}") | |||
| public ResultData loginByPhone(@RequestBody Map<String, String> map) { | |||
| public ResultData loginByPhone(@RequestBody Map<String, String> map, HttpServletRequest request) { | |||
| String ipAddr = getIpAddr(); | |||
| logger.debug("[" + ipAddr + "] WxUserGrantController::loginByPhone"); | |||
| String code = map.get("code"); | |||
| @@ -160,8 +164,19 @@ public class WxUserGrantController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); | |||
| } | |||
| String key = Constant.captchaPrev + ":" + ipAddr; | |||
| String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| HttpSession session = request.getSession(); | |||
| Object kaptcha = session.getAttribute(Constants.KAPTCHA_SESSION_KEY); | |||
| if(kaptcha == null){ | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID); | |||
| } | |||
| session.removeAttribute(Constants.KAPTCHA_SESSION_KEY); | |||
| if(!kaptcha.toString().equals(code)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||
| } | |||
| // String key = Constant.captchaPrev + ":" + ipAddr; | |||
| // String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| // if (StringUtils.isBlank(code1)) { | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||
| // } | |||
| @@ -205,23 +220,32 @@ public class WxUserGrantController extends BaseController { | |||
| @AuthIgnore | |||
| @PostMapping("/loginByEmail") | |||
| @ApiOperation(value = "用户登录", notes = "{\"email\":\"string\",\"password\":\"string\",\"code\":\"string\"}") | |||
| public ResultData loginByEmail(@RequestBody Map<String, String> map) { | |||
| public ResultData loginByEmail(@RequestBody Map<String, String> map, HttpServletRequest request) { | |||
| String ipAddr = getIpAddr(); | |||
| logger.debug("[" + ipAddr + "] WxUserGrantController::loginByEmail"); | |||
| String code = map.get("code"); | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); | |||
| } | |||
| String key = Constant.captchaPrev + ":" + ipAddr; | |||
| String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| if (StringUtils.isBlank(code1)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||
| HttpSession session = request.getSession(); | |||
| Object kaptcha = session.getAttribute(Constants.KAPTCHA_SESSION_KEY); | |||
| if(kaptcha == null){ | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID); | |||
| } | |||
| if (!code1.equals(code)) { | |||
| session.removeAttribute(Constants.KAPTCHA_SESSION_KEY); | |||
| if(!kaptcha.toString().equals(code)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||
| } | |||
| // String key = Constant.captchaPrev + ":" + ipAddr; | |||
| // String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| // if (StringUtils.isBlank(code1)) { | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||
| // } | |||
| // if (!code1.equals(code)) { | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||
| // } | |||
| String email = map.get("email"); | |||
| String password = map.get("password"); | |||
| if (StringUtils.isBlank(email) || StringUtils.isBlank(password)) { | |||
| @@ -337,7 +361,7 @@ public class WxUserGrantController extends BaseController { | |||
| @GetMapping("sendPhoneCode") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData sendPhoneCode(String phone, String code) { | |||
| public ResultData sendPhoneCode(String phone, String code, HttpServletRequest request) { | |||
| String ipAddr = getIpAddr(); | |||
| logger.debug("[" + ipAddr + "] WxUserGrantController::sendPhoneCode"); | |||
| if (StringUtils.isBlank(phone)) { | |||
| @@ -346,15 +370,24 @@ public class WxUserGrantController extends BaseController { | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "请输入验证码"); | |||
| } | |||
| String key = Constant.captchaPrev + ":" + ipAddr; | |||
| String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| if (StringUtils.isBlank(code1)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||
| HttpSession session = request.getSession(); | |||
| Object kaptcha = session.getAttribute(Constants.KAPTCHA_SESSION_KEY); | |||
| if(kaptcha == null){ | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID); | |||
| } | |||
| if (!code1.equals(code)) { | |||
| session.removeAttribute(Constants.KAPTCHA_SESSION_KEY); | |||
| if(!kaptcha.toString().equals(code)){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||
| } | |||
| // String key = Constant.captchaPrev + ":" + ipAddr; | |||
| // String code1 = RedisCacheUtils.getCacheString(redisTemplate, key); | |||
| // if (StringUtils.isBlank(code1)) { | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码已过期"); | |||
| // } | |||
| // if (!code1.equals(code)) { | |||
| // return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "验证码不正确"); | |||
| // } | |||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(getTenantInfo(), phone); | |||
| if (basicInfo == null) { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(), "该手机号未注册"); | |||
| @@ -44,7 +44,7 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| AuthIgnore annotation; | |||
| if(handler instanceof HandlerMethod) { | |||
| annotation = ((HandlerMethod) handler).getMethodAnnotation(AuthIgnore.class); | |||
| @@ -190,11 +190,26 @@ logging: | |||
| suimang: | |||
| oral_broadcasting: http://111.198.0.15:22266 | |||
| callbackUrl: https://test.metavatar.cc/C | |||
| photo_speak: xxx | |||
| photo_speak_hy: xxx | |||
| digital_avatar: xxx | |||
| digital_avatar_hy: xxx | |||
| video_tts: http://111.198.0.15:22222 | |||
| photo_speak: http://111.198.0.15:22299 | |||
| photo_speak_hy: http://111.198.0.15:22288 | |||
| digital_avatar: http://nas.pucao.cn:2005 | |||
| digital_avatar_hy: http://nas.pucao.cn:2003 | |||
| callbackUrl: https://mtest.metavatar.cc/C | |||
| sdk: | |||
| sm: | |||
| base-url: https://mtest.metavatar.cc/public | |||
| swagger: | |||
| base-package: com.iformall.controller | |||
| title: 遂芒_metavatar_接口文档 | |||
| description: 前后端联调 | |||
| version: 1.0 | |||
| license: Apache | |||
| license-url: https://mtest.metavatar.cc/ | |||
| terms-of-service-url: https://mtest.metavatar.cc/ | |||
| host: localhost:8888 | |||
| contact: | |||
| name: 张三 | |||
| url: https://mtest.metavatar.cc/ | |||
| email: zhangsan@163.com | |||
| @@ -51,8 +51,6 @@ public class MqBaseConsumer { | |||
| //@Autowired | |||
| //private FmInsideNotifyPaySuccessMsgServiceImpl fmInsideNotifyPaySuccessMsgService; | |||
| @Autowired | |||
| private FmInsideNotifyRefundSuccessMsgServiceImpl fmInsideNotifyRefundSuccessMsgService; | |||
| //@Autowired | |||
| //UpdateCouponStockMsgServiceImpl updateCouponStockMsgService; | |||
| @@ -160,8 +158,6 @@ public class MqBaseConsumer { | |||
| //} | |||
| else if(EnumMsgRecordType.INSIDE_NOTIFY_REFUND_SUCCESS.getCode().equals(baseMsg.getMsgType())) { | |||
| // 内部消息 - 微信退款通知 | |||
| FmInsideNotifyRefundSuccessMsg msg = (FmInsideNotifyRefundSuccessMsg)JsonUtil.readValue(message,FmInsideNotifyRefundSuccessMsg.class); | |||
| fmInsideNotifyRefundSuccessMsgService.send(msg); | |||
| } | |||
| else if(EnumMsgRecordType.CASH_OUT.getCode().equals(baseMsg.getMsgType())) { | |||
| // 内部消息 - 商户提现通知 | |||
| @@ -193,8 +193,9 @@ logging: | |||
| suimang: | |||
| oral_broadcasting: http://nas.pucao.cn:2001 | |||
| video_tts: http://111.198.0.15:22222 | |||
| photo_speak: http://111.198.0.15:22299 | |||
| photo_speak_hy: http://111.198.0.15:22288 | |||
| digital_avatar: http://111.198.0.15:22200 | |||
| digital_avatar: http://nas.pucao.cn:2005 | |||
| digital_avatar_hy: http://nas.pucao.cn:2003 | |||
| callbackUrl: https://test.metavatar.cc/C | |||
| callbackUrl: https://mtest.metavatar.cc/C | |||
| @@ -149,6 +149,7 @@ logging: | |||
| suimang: | |||
| oral_broadcasting: http://111.198.0.15:22266 | |||
| video_tts: http://111.198.0.15:22222 | |||
| photo_speak: http://111.198.0.15:22299 | |||
| photo_speak_hy: http://111.198.0.15:22288 | |||
| digital_avatar: http://111.198.0.15:22200 | |||
| @@ -20,6 +20,11 @@ | |||
| <scope>compile</scope> | |||
| </dependency> | |||
| --> | |||
| <dependency> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>suimang-swagger</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>suimangVideo</artifactId> | |||
| @@ -1,6 +1,12 @@ | |||
| package com.iformall.common; | |||
| public interface CommonConstants { | |||
| /** | |||
| * 接口响应码:200:成功 500:失败 | |||
| */ | |||
| Integer SUCCESS = 200; | |||
| Integer FAILED = 500; | |||
| /** | |||
| * 状态(0:正常,1:锁定) | |||
| */ | |||
| @@ -8,8 +14,16 @@ public interface CommonConstants { | |||
| Integer STATUS_ABNORMAL = 1; | |||
| /** | |||
| * 删除状态(0:未删除,1:已删除) | |||
| * 是否:0:否,1:是 | |||
| * 是否删除状态(0:未删除,1:已删除) | |||
| */ | |||
| Integer FLAG_TRUE = 1; | |||
| Integer FLAG_FALSE = 0; | |||
| /** | |||
| * 通用数字 | |||
| */ | |||
| Integer DEL_FLAG_DELETED = 1; | |||
| Integer DEL_FLAG_NORMAL = 0; | |||
| int NUM_0 = 0; | |||
| int NUM_1 = 1; | |||
| int NUM_2 = 2; | |||
| } | |||
| @@ -678,6 +678,12 @@ public enum ErrorCode{ | |||
| ORDER_CREAT_OVERRUN(64000, "重复生成次数超限"), | |||
| CODE_ALREADY_EXISTS(71000, "该code已存在"), | |||
| SECRET_NOT_EXISTS(71001, "该秘钥不存在"), | |||
| SERVICE_LOCKED(71002, "合作商被锁定,无法修改"), | |||
| NAME_REPEAT(81000, "名称重复"), | |||
| EXIST_AVAILABLE_GUIDE(81001, "存在可用指南"), | |||
| ; | |||
| private int code; | |||
| @@ -0,0 +1,76 @@ | |||
| package com.iformall.common; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.io.Serializable; | |||
| /** | |||
| * 响应信息主体 | |||
| * | |||
| * @author xmzhao71 | |||
| * @date 2023-10-26 | |||
| */ | |||
| @ApiModel(description = "响应信息主体") | |||
| @Data | |||
| public class R<T> implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @ApiModelProperty(value = "返回标记:成功=0,失败=1") | |||
| private int code; | |||
| @ApiModelProperty(value = "返回信息") | |||
| private String message; | |||
| @ApiModelProperty(value = "数据") | |||
| private T data; | |||
| public Boolean isOk() { | |||
| return code == 200; | |||
| } | |||
| public static <T> R<T> ok() { | |||
| return restResult(null, CommonConstants.SUCCESS, null); | |||
| } | |||
| public static <T> R<T> ok(T data) { | |||
| return restResult(data, CommonConstants.SUCCESS, null); | |||
| } | |||
| public static <T> R<T> ok(T data, String msg) { | |||
| return restResult(data, CommonConstants.SUCCESS, msg); | |||
| } | |||
| public static <T> R<T> failed() { | |||
| return restResult(null, CommonConstants.FAILED, null); | |||
| } | |||
| public static <T> R<T> failed(String msg) { | |||
| return restResult(null, CommonConstants.FAILED, msg); | |||
| } | |||
| public static <T> R<T> failed(T data) { | |||
| return restResult(data, CommonConstants.FAILED, null); | |||
| } | |||
| public static <T> R<T> failed(T data, String msg) { | |||
| return restResult(data, CommonConstants.FAILED, msg); | |||
| } | |||
| public static <T> R<T> failed(T data, int code, String msg) { | |||
| return restResult(data, code, msg); | |||
| } | |||
| public static <T> R<T> failed(int code, String msg) { | |||
| return restResult(null, code, msg); | |||
| } | |||
| private static <T> R<T> restResult(T data, int code, String msg) { | |||
| R<T> apiResult = new R<>(); | |||
| apiResult.setCode(code); | |||
| apiResult.setData(data); | |||
| apiResult.setMessage(msg); | |||
| return apiResult; | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.domain.dto.neuver; | |||
| package com.iformall.domain.dto.sm; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.common.CommonConstants; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.sm.ApiGuide; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @ApiModel(value = "新增API指南") | |||
| @Data | |||
| public class SaveApiGuideDTO { | |||
| @ApiModelProperty("指南名称") | |||
| private String name; | |||
| @ApiModelProperty("指南内容") | |||
| private String content; | |||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||
| private Integer status; | |||
| public static ApiGuide mapping(SaveApiGuideDTO dto) { | |||
| ApiGuide apiGuide = new ApiGuide(); | |||
| apiGuide.setId(IdWorker.get().nextId()); | |||
| apiGuide.setCreateTime(new Date()); | |||
| apiGuide.setUpdateTime(new Date()); | |||
| if (CommonConstants.STATUS_NORMAL.equals(dto.getStatus())) { | |||
| apiGuide.setReleaseTime(new Date()); | |||
| } | |||
| apiGuide.setName(dto.getName()); | |||
| apiGuide.setContent(dto.getContent()); | |||
| apiGuide.setStatus(dto.getStatus()); | |||
| apiGuide.setDeleteFlag(CommonConstants.FLAG_FALSE); | |||
| return apiGuide; | |||
| } | |||
| } | |||
| @@ -0,0 +1,74 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.common.CommonConstants; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.sm.ApiDetail; | |||
| import com.iformall.domain.po.sm.ApiMenu; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @ApiModel(value = "新增API菜单") | |||
| @Data | |||
| public class SaveApiMenuDTO { | |||
| @ApiModelProperty("菜单名称") | |||
| private String name; | |||
| @ApiModelProperty("父菜单id") | |||
| private Long parentId; | |||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||
| private Integer status; | |||
| @ApiModelProperty("是否付费(0:否,1:是)") | |||
| private Integer chargeFlag; | |||
| @ApiModelProperty("是否需用户授权(0:否,1:是)") | |||
| private Integer authFlag; | |||
| @ApiModelProperty("接口描述") | |||
| private String description; | |||
| @ApiModelProperty("平台地址") | |||
| private String platformUrl; | |||
| @ApiModelProperty("系统参数") | |||
| private String publicParam; | |||
| @ApiModelProperty("请求参数") | |||
| private String requestParam; | |||
| @ApiModelProperty("响应参数") | |||
| private String responseParam; | |||
| @ApiModelProperty("请求示例") | |||
| private String requestSample; | |||
| @ApiModelProperty("响应示例") | |||
| private String responseSample; | |||
| @ApiModelProperty("异常示例") | |||
| private String exceptionSample; | |||
| public static ApiMenu mapping(SaveApiMenuDTO dto) { | |||
| ApiMenu apiMenu = new ApiMenu(); | |||
| apiMenu.setId(IdWorker.get().nextId()); | |||
| apiMenu.setCreateTime(new Date()); | |||
| apiMenu.setUpdateTime(new Date()); | |||
| apiMenu.setName(dto.getName()); | |||
| apiMenu.setParentId(dto.getParentId()); | |||
| apiMenu.setStatus(dto.getStatus()); | |||
| apiMenu.setDeleteFlag(CommonConstants.FLAG_FALSE); | |||
| return apiMenu; | |||
| } | |||
| public static ApiDetail mappingApiDetail(SaveApiMenuDTO dto, ApiMenu apiMenu) { | |||
| ApiDetail apiDetail = new ApiDetail(); | |||
| apiDetail.setId(IdWorker.get().nextId()); | |||
| apiDetail.setCreateTime(new Date()); | |||
| apiDetail.setUpdateTime(new Date()); | |||
| apiDetail.setMenuId(apiMenu.getId()); | |||
| apiDetail.setMenuName(apiMenu.getName()); | |||
| apiDetail.setChargeFlag(dto.getChargeFlag()); | |||
| apiDetail.setAuthFlag(dto.getAuthFlag()); | |||
| apiDetail.setDescription(dto.getDescription()); | |||
| apiDetail.setPlatformUrl(dto.getPlatformUrl()); | |||
| apiDetail.setPublicParam(dto.getPublicParam()); | |||
| apiDetail.setRequestParam(dto.getRequestParam()); | |||
| apiDetail.setResponseParam(dto.getResponseParam()); | |||
| apiDetail.setRequestSample(dto.getRequestSample()); | |||
| apiDetail.setResponseSample(dto.getResponseSample()); | |||
| apiDetail.setExceptionSample(dto.getExceptionSample()); | |||
| return apiDetail; | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.domain.dto.neuver; | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.common.CommonConstants; | |||
| import com.iformall.common.IdWorker; | |||
| @@ -16,7 +16,7 @@ public class SaveServiceInfoDTO { | |||
| private String name; | |||
| @ApiModelProperty("所在地址") | |||
| private String address; | |||
| @ApiModelProperty("客户唯一凭证,api接入需提供") | |||
| @ApiModelProperty("客户唯一凭证") | |||
| private String code; | |||
| @ApiModelProperty("接入方式(1:api接入,2:私有化接入)") | |||
| private Integer type; | |||
| @@ -1,17 +1,21 @@ | |||
| package com.iformall.domain.dto.neuver; | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.sm.ServiceVideoRecord; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.AllArgsConstructor; | |||
| import lombok.Builder; | |||
| import lombok.Data; | |||
| import lombok.NoArgsConstructor; | |||
| import java.util.Date; | |||
| @ApiModel(value = "新增生成视频时长记录") | |||
| @Data | |||
| @Builder | |||
| @NoArgsConstructor | |||
| @AllArgsConstructor | |||
| public class SaveServiceVideoRecordDTO { | |||
| @ApiModelProperty("接入商标识") | |||
| private Long serviceId; | |||
| @@ -0,0 +1,22 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.AllArgsConstructor; | |||
| import lombok.Builder; | |||
| import lombok.Data; | |||
| import lombok.NoArgsConstructor; | |||
| @ApiModel(value = "新增开放接口秘钥") | |||
| @Data | |||
| @Builder | |||
| @NoArgsConstructor | |||
| @AllArgsConstructor | |||
| public class SaveThirdPartyApiDTO { | |||
| @ApiModelProperty("第三方类型(1:API接入,2:私有化接入)") | |||
| private Integer type; | |||
| @ApiModelProperty("名称") | |||
| private String name; | |||
| @ApiModelProperty("接入商id") | |||
| private Long serviceId; | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.common.CommonConstants; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.sm.ApiGuide; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @ApiModel(value = "修改API指南") | |||
| @Data | |||
| public class UpdateApiGuideDTO { | |||
| @ApiModelProperty("id") | |||
| private Long id; | |||
| @ApiModelProperty("api名称") | |||
| private String name; | |||
| @ApiModelProperty("指南内容") | |||
| private String content; | |||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||
| private Integer status; | |||
| public static ApiGuide mapping(UpdateApiGuideDTO dto) { | |||
| ApiGuide apiGuide = new ApiGuide(); | |||
| apiGuide.setId(dto.getId()); | |||
| apiGuide.setUpdateTime(new Date()); | |||
| if (CommonConstants.STATUS_NORMAL.equals(dto.getStatus())) { | |||
| apiGuide.setReleaseTime(new Date()); | |||
| } | |||
| apiGuide.setName(dto.getName()); | |||
| apiGuide.setContent(dto.getContent()); | |||
| apiGuide.setStatus(dto.getStatus()); | |||
| return apiGuide; | |||
| } | |||
| } | |||
| @@ -0,0 +1,74 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.common.CommonConstants; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.sm.ApiDetail; | |||
| import com.iformall.domain.po.sm.ApiMenu; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @ApiModel(value = "修改API菜单") | |||
| @Data | |||
| public class UpdateApiMenuDTO { | |||
| @ApiModelProperty(value = "菜单id",required = true) | |||
| private Long id; | |||
| @ApiModelProperty(value = "详情id") | |||
| private Long detailId; | |||
| @ApiModelProperty("菜单名称") | |||
| private String name; | |||
| @ApiModelProperty("父菜单id") | |||
| private Long parentId; | |||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||
| private Integer status; | |||
| @ApiModelProperty("是否付费(0:否,1:是)") | |||
| private Integer chargeFlag; | |||
| @ApiModelProperty("是否需用户授权(0:否,1:是)") | |||
| private Integer authFlag; | |||
| @ApiModelProperty("接口描述") | |||
| private String description; | |||
| @ApiModelProperty("平台地址") | |||
| private String platformUrl; | |||
| @ApiModelProperty("系统参数") | |||
| private String publicParam; | |||
| @ApiModelProperty("请求参数") | |||
| private String requestParam; | |||
| @ApiModelProperty("响应参数") | |||
| private String responseParam; | |||
| @ApiModelProperty("请求示例") | |||
| private String requestSample; | |||
| @ApiModelProperty("响应示例") | |||
| private String responseSample; | |||
| @ApiModelProperty("异常示例") | |||
| private String exceptionSample; | |||
| public static ApiMenu mapping(UpdateApiMenuDTO dto) { | |||
| ApiMenu apiMenu = new ApiMenu(); | |||
| apiMenu.setId(dto.getId()); | |||
| apiMenu.setUpdateTime(new Date()); | |||
| apiMenu.setName(dto.getName()); | |||
| apiMenu.setParentId(dto.getParentId()); | |||
| apiMenu.setStatus(dto.getStatus()); | |||
| return apiMenu; | |||
| } | |||
| public static ApiDetail mappingApiDetail(UpdateApiMenuDTO dto) { | |||
| ApiDetail apiDetail = new ApiDetail(); | |||
| apiDetail.setUpdateTime(new Date()); | |||
| apiDetail.setMenuId(dto.getId()); | |||
| apiDetail.setMenuName(dto.getName()); | |||
| apiDetail.setChargeFlag(dto.getChargeFlag()); | |||
| apiDetail.setAuthFlag(dto.getAuthFlag()); | |||
| apiDetail.setDescription(dto.getDescription()); | |||
| apiDetail.setPlatformUrl(dto.getPlatformUrl()); | |||
| apiDetail.setPublicParam(dto.getPublicParam()); | |||
| apiDetail.setRequestParam(dto.getRequestParam()); | |||
| apiDetail.setResponseParam(dto.getResponseParam()); | |||
| apiDetail.setRequestSample(dto.getRequestSample()); | |||
| apiDetail.setResponseSample(dto.getResponseSample()); | |||
| apiDetail.setExceptionSample(dto.getExceptionSample()); | |||
| return apiDetail; | |||
| } | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import com.iformall.domain.po.sm.ServiceInfo; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @ApiModel(value = "修改接入商") | |||
| @Data | |||
| public class UpdateServiceInfoDTO { | |||
| @ApiModelProperty("id") | |||
| private Long id; | |||
| @ApiModelProperty("客户名称") | |||
| private String name; | |||
| @ApiModelProperty("所在地址") | |||
| private String address; | |||
| public static ServiceInfo mapping(UpdateServiceInfoDTO dto) { | |||
| ServiceInfo serviceInfo = new ServiceInfo(); | |||
| serviceInfo.setId(dto.getId()); | |||
| serviceInfo.setUpdateTime(new Date()); | |||
| serviceInfo.setName(dto.getName()); | |||
| serviceInfo.setAddress(dto.getAddress()); | |||
| return serviceInfo; | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| @ApiModel(value = "更新接入商状态") | |||
| @Data | |||
| public class UpdateServiceInfoStatusDTO { | |||
| @ApiModelProperty("接入商id") | |||
| private Long id; | |||
| @ApiModelProperty("状态(0:正常,1:失效)") | |||
| private Integer status; | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.domain.dto.sm; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| @ApiModel(value = "更新开放接口秘钥状态") | |||
| @Data | |||
| public class UpdateThirdPartyApiStatusDTO { | |||
| @ApiModelProperty("开放接口秘钥id") | |||
| private Long id; | |||
| @ApiModelProperty("状态(0:正常,1:失效)") | |||
| private Integer status; | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "level_package") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class LevelPackage extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="等级",name="level") | |||
| private Integer level; | |||
| @io.swagger.annotations.ApiModelProperty(value="名称",name="name") | |||
| private String name; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="en_name") | |||
| private String en_name; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐色",name="color") | |||
| private String color; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="priceDollar") | |||
| private Integer priceDollar; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="priceRmb") | |||
| private Integer priceRmb; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐积分",name="credit") | |||
| private Integer credit; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐时长",name="validityDuration") | |||
| private Integer validityDuration; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| private Date endDate; | |||
| } | |||
| @@ -0,0 +1,121 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.sm.EnumAiTemplateType; | |||
| import com.iformall.enums.sm.EnumLanguageType; | |||
| import com.iformall.enums.sm.EnumSoundType; | |||
| import com.iformall.enums.sm.EnumVideoFormatType; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "project_package_detail") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class ProjectPackageDetail extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="项目",name="projectType") | |||
| private Integer projectType; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐ID",name="packageId") | |||
| private Long packageId; | |||
| @io.swagger.annotations.ApiModelProperty(value="邀请用户加积分数量",name="inviteUserCredit") | |||
| private Integer inviteUserCredit; | |||
| @io.swagger.annotations.ApiModelProperty(value="ai生成照片价格",name="aiPhotoPrice") | |||
| private Integer aiPhotoPrice; | |||
| @io.swagger.annotations.ApiModelProperty(value="ai生成脚本价格",name="aiScriptPrice") | |||
| private Integer aiScriptPrice; | |||
| @io.swagger.annotations.ApiModelProperty(value="生成视频价格",name="videoPrice") | |||
| private Integer videoPrice; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否有水印",name="isVideoWatermark") | |||
| private Integer isVideoWatermark; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumLanguageType",name="language") | |||
| private Integer language; | |||
| @TableField(exist = false) | |||
| private String languageDesc; | |||
| public String getLanguageDesc(){ | |||
| if(this.language != null){ | |||
| EnumLanguageType languageEnum = EnumLanguageType.getEnum(language); | |||
| if(languageEnum != null){ | |||
| languageDesc = languageEnum.getMessage(); | |||
| } | |||
| } | |||
| return languageDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumSoundType",name="sound") | |||
| private Integer sound; | |||
| @TableField(exist = false) | |||
| private String soundDesc; | |||
| public String getSoundDesc(){ | |||
| if(this.sound != null){ | |||
| EnumSoundType soundEnum = EnumSoundType.getEnum(sound); | |||
| if(soundEnum != null){ | |||
| soundDesc = soundEnum.getMessage(); | |||
| } | |||
| } | |||
| return soundDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="生成视频最大时长(s)",name="videoTime") | |||
| private Integer videoTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="可生成照片的次数",name="aiPhoto") | |||
| private Integer aiPhoto; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否可唱歌",name="isSing") | |||
| private Integer isSing; | |||
| @io.swagger.annotations.ApiModelProperty(value="可生成脚本的次数",name="aiScript") | |||
| private Integer aiScript; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumVideoFormatType",name="videoFormat") | |||
| private Integer videoFormat; | |||
| @TableField(exist = false) | |||
| private String videoFormatDesc; | |||
| public String getVideoFormatDesc(){ | |||
| if(this.videoFormat != null){ | |||
| EnumVideoFormatType videoFormatEnum = EnumVideoFormatType.getEnum(videoFormat); | |||
| if(videoFormatEnum != null){ | |||
| videoFormatDesc = videoFormatEnum.getMessage(); | |||
| } | |||
| } | |||
| return videoFormatDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumAiTemplateType",name="template") | |||
| private Integer template; | |||
| @TableField(exist = false) | |||
| private String templateDesc; | |||
| public String getTemplateDesc(){ | |||
| if(this.template != null){ | |||
| EnumAiTemplateType templateEnum = EnumAiTemplateType.getEnum(template); | |||
| if(templateEnum != null){ | |||
| templateDesc = templateEnum.getMessage(); | |||
| } | |||
| } | |||
| return templateDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| private Date endDate; | |||
| } | |||
| @@ -0,0 +1,52 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "user_level_package") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class UserLevelPackage extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐ID",name="packageId") | |||
| private Long packageId; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐等级",name="packageLevel") | |||
| private Integer packageLevel; | |||
| @io.swagger.annotations.ApiModelProperty(value="套餐色",name="packageColor") | |||
| private String packageColor; | |||
| @io.swagger.annotations.ApiModelProperty(value="用户总积分",name="userCredits") | |||
| private Integer userCredits; | |||
| @io.swagger.annotations.ApiModelProperty(value="剩余积分",name="residueCredits") | |||
| private Integer residueCredits; | |||
| @io.swagger.annotations.ApiModelProperty(value="到期时间",name="expiresDate") | |||
| private Date expiresDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="updateDate") | |||
| private Date updateDate; | |||
| @TableField(exist = false) | |||
| private Integer addCredits; | |||
| @TableField(exist = false) | |||
| private Integer addSumCredits; | |||
| @TableField(exist = false) | |||
| private Integer reduceCredits; | |||
| } | |||
| @@ -77,22 +77,6 @@ public class WxPayAccount extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="销售提点",name="sellRate") | |||
| private Integer sellRate; | |||
| public String getPayNotifyV3Url(Integer projectType) { | |||
| if(projectType == null){ | |||
| return notifyUrl + "/pay/v3"; | |||
| } | |||
| return notifyUrl + "/" + projectType + "/pay/v3"; | |||
| } | |||
| public String getPayNotifyUrl() { | |||
| return notifyUrl + "/pay"; | |||
| } | |||
| public String getRefundNotifyV3Url() { | |||
| return notifyUrl + "/refund/v3"; | |||
| } | |||
| public String getRefundNotifyUrl() { | |||
| return notifyUrl + "/refund"; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="微信支付分serviceId",name="serviceId") | |||
| private String serviceId; | |||
| @io.swagger.annotations.ApiModelProperty(value="微信支付分回调地址",name="payScoreNotifyUrl") | |||
| @@ -0,0 +1,96 @@ | |||
| package com.iformall.domain.po.sm; | |||
| import com.baomidou.mybatisplus.annotation.IdType; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableId; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| /** | |||
| * | |||
| * @TableName api_detail | |||
| */ | |||
| @TableName(value ="api_detail") | |||
| @Data | |||
| public class ApiDetail implements Serializable { | |||
| /** | |||
| * 详情id | |||
| */ | |||
| @TableId | |||
| private Long id; | |||
| /** | |||
| * 创建时间 | |||
| */ | |||
| private Date createTime; | |||
| /** | |||
| * 修改时间 | |||
| */ | |||
| private Date updateTime; | |||
| /** | |||
| * 菜单id | |||
| */ | |||
| private Long menuId; | |||
| /** | |||
| * 菜单名称 | |||
| */ | |||
| private String menuName; | |||
| /** | |||
| * 是否付费(0:否,1:是) | |||
| */ | |||
| private Integer chargeFlag; | |||
| /** | |||
| * 是否需用户授权(0:否,1:是) | |||
| */ | |||
| private Integer authFlag; | |||
| /** | |||
| * 描述 | |||
| */ | |||
| private String description; | |||
| /** | |||
| * 平台地址 | |||
| */ | |||
| private String platformUrl; | |||
| /** | |||
| * 系统参数 | |||
| */ | |||
| private String publicParam; | |||
| /** | |||
| * 请求参数 | |||
| */ | |||
| private String requestParam; | |||
| /** | |||
| * 响应参数 | |||
| */ | |||
| private String responseParam; | |||
| /** | |||
| * 请求示例 | |||
| */ | |||
| private String requestSample; | |||
| /** | |||
| * 响应示例 | |||
| */ | |||
| private String responseSample; | |||
| /** | |||
| * 异常示例 | |||
| */ | |||
| private String exceptionSample; | |||
| @TableField(exist = false) | |||
| private static final long serialVersionUID = 1L; | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package com.iformall.domain.po.sm; | |||
| import com.baomidou.mybatisplus.annotation.IdType; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableId; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| /** | |||
| * | |||
| * @TableName api_guide | |||
| */ | |||
| @TableName(value ="api_guide") | |||
| @Data | |||
| public class ApiGuide implements Serializable { | |||
| /** | |||
| * 主键id | |||
| */ | |||
| @TableId | |||
| private Long id; | |||
| /** | |||
| * 创建时间 | |||
| */ | |||
| private Date createTime; | |||
| /** | |||
| * 修改时间 | |||
| */ | |||
| private Date updateTime; | |||
| /** | |||
| * 发布时间 | |||
| */ | |||
| private Date releaseTime; | |||
| /** | |||
| * 指南名称 | |||
| */ | |||
| private String name; | |||
| /** | |||
| * 指南内容 | |||
| */ | |||
| private String content; | |||
| /** | |||
| * 状态(0:正常,1:锁定) | |||
| */ | |||
| private Integer status; | |||
| /** | |||
| * 删除(0:未删除,1:删除) | |||
| */ | |||
| private Integer deleteFlag; | |||
| @TableField(exist = false) | |||
| private static final long serialVersionUID = 1L; | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package com.iformall.domain.po.sm; | |||
| import com.baomidou.mybatisplus.annotation.IdType; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableId; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import lombok.Data; | |||
| /** | |||
| * | |||
| * @TableName api_menu | |||
| */ | |||
| @TableName(value ="api_menu") | |||
| @Data | |||
| public class ApiMenu implements Serializable { | |||
| /** | |||
| * 菜单id | |||
| */ | |||
| @TableId | |||
| private Long id; | |||
| /** | |||
| * 创建时间 | |||
| */ | |||
| private Date createTime; | |||
| /** | |||
| * 修改时间 | |||
| */ | |||
| private Date updateTime; | |||
| /** | |||
| * 菜单名称 | |||
| */ | |||
| private String name; | |||
| /** | |||
| * 父菜单id | |||
| */ | |||
| private Long parentId; | |||
| /** | |||
| * 状态(0:正常,1:锁定) | |||
| */ | |||
| private Integer status; | |||
| /** | |||
| * 是否叶子节点(0:否,1:是) | |||
| */ | |||
| private Integer leafFlag; | |||
| /** | |||
| * 是否删除(0:未删除,1:删除) | |||
| */ | |||
| private Integer deleteFlag; | |||
| @TableField(exist = false) | |||
| private static final long serialVersionUID = 1L; | |||
| } | |||
| @@ -44,7 +44,7 @@ public class ServiceInfo { | |||
| @TableField("address") | |||
| private String address; | |||
| /** | |||
| * 客户唯一凭证,api接入需提供 | |||
| * 客户唯一凭证 | |||
| */ | |||
| @TableField("code") | |||
| private String code; | |||
| @@ -0,0 +1,48 @@ | |||
| package com.iformall.domain.vo.sm; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| @ApiModel(value = "查询API菜单响应数据") | |||
| @Data | |||
| public class ApiMenuVO { | |||
| @ApiModelProperty("菜单id") | |||
| private Long id; | |||
| @ApiModelProperty("创建时间") | |||
| private Date createTime; | |||
| @ApiModelProperty("修改时间") | |||
| private Date updateTime; | |||
| @ApiModelProperty("是否叶子节点(0:否,1:是)") | |||
| private Integer leafFlag; | |||
| @ApiModelProperty("菜单名称") | |||
| private String name; | |||
| @ApiModelProperty("父菜单id") | |||
| private Long parentId; | |||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||
| private Integer status; | |||
| @ApiModelProperty("详情id") | |||
| private Long detailId; | |||
| @ApiModelProperty("是否付费(0:否,1:是)") | |||
| private Integer chargeFlag; | |||
| @ApiModelProperty("是否需用户授权(0:否,1:是)") | |||
| private Integer authFlag; | |||
| @ApiModelProperty("接口描述") | |||
| private String description; | |||
| @ApiModelProperty("平台地址") | |||
| private String platformUrl; | |||
| @ApiModelProperty("系统参数") | |||
| private String publicParam; | |||
| @ApiModelProperty("请求参数") | |||
| private String requestParam; | |||
| @ApiModelProperty("响应参数") | |||
| private String responseParam; | |||
| @ApiModelProperty("请求示例") | |||
| private String requestSample; | |||
| @ApiModelProperty("响应示例") | |||
| private String responseSample; | |||
| @ApiModelProperty("异常示例") | |||
| private String exceptionSample; | |||
| } | |||
| @@ -0,0 +1,27 @@ | |||
| package com.iformall.domain.vo.sm; | |||
| import com.iformall.domain.po.sm.ApiDetail; | |||
| import com.iformall.domain.po.sm.ApiMenu; | |||
| import io.swagger.annotations.ApiModel; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Data; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @ApiModel(value = "查询某个api菜单所有子菜单相应数据") | |||
| @Data | |||
| public class ListApiSubmenuVO { | |||
| @ApiModelProperty("菜单id") | |||
| private Long id; | |||
| @ApiModelProperty("修改时间") | |||
| private Date updateTime; | |||
| @ApiModelProperty("菜单名称") | |||
| private String name; | |||
| @ApiModelProperty("状态(0:正常,1:锁定)") | |||
| private Integer status; | |||
| @ApiModelProperty("详情id") | |||
| private Long detailId; | |||
| @ApiModelProperty("接口描述") | |||
| private String description; | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| package com.iformall.domain.vo.sm; | |||
| import io.swagger.annotations.ApiModel; | |||
| import lombok.Data; | |||
| @ApiModel(value = "音色预览请求参数") | |||
| @Data | |||
| public class PreviewVoiceVO { | |||
| private Double time; | |||
| private String url; | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.enums.sm; | |||
| /** | |||
| * 数字人模板 | |||
| */ | |||
| public enum EnumAiTemplateType { | |||
| FREE(1, "免费"), | |||
| VIP(2, "VIP"); | |||
| public static EnumAiTemplateType getEnum(Integer code) { | |||
| for (EnumAiTemplateType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumAiTemplateType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.enums.sm; | |||
| /** | |||
| * 数字人模板 | |||
| */ | |||
| public enum EnumTemplateType { | |||
| FREE(1, "免费"), | |||
| VIP(2, "VIP"); | |||
| public static EnumTemplateType getEnum(Integer code) { | |||
| for (EnumTemplateType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumTemplateType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.enums.sm; | |||
| public enum EnumThirdPartyType { | |||
| API_JOIN(1, "API接入"), | |||
| PRIVATE_JOIN(2, "私有化接入"); | |||
| public static EnumThirdPartyType getEnum(Integer code) { | |||
| for (EnumThirdPartyType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumThirdPartyType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,34 @@ | |||
| package com.iformall.enums.sm; | |||
| /** | |||
| * 分辨率 | |||
| */ | |||
| public enum EnumVideoFormatType { | |||
| VIDEOFORMAT_720P(1, "720p"), | |||
| VIDEOFORMAT_1080P(2, "1080p"); | |||
| public static EnumVideoFormatType getEnum(Integer code) { | |||
| for (EnumVideoFormatType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumVideoFormatType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,15 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.domain.po.sm.ApiDetail; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| /** | |||
| * @Entity com.iformall.domain.po.sm.ApiDetail | |||
| */ | |||
| public interface ApiDetailMapper extends BaseMapper<ApiDetail> { | |||
| } | |||
| @@ -0,0 +1,18 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.domain.po.sm.ApiGuide; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import java.util.List; | |||
| /** | |||
| * @Entity com.iformall.domain.po.sm.ApiGuide | |||
| */ | |||
| public interface ApiGuideMapper extends BaseMapper<ApiGuide> { | |||
| List<ApiGuide> listApiGuide(ApiGuide apiGuide); | |||
| } | |||
| @@ -0,0 +1,26 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.domain.po.sm.ApiMenu; | |||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
| import com.iformall.domain.vo.sm.ApiMenuVO; | |||
| import com.iformall.domain.vo.sm.ListApiSubmenuVO; | |||
| import java.util.List; | |||
| /** | |||
| * @Entity com.iformall.domain.po.sm.ApiMenu | |||
| */ | |||
| public interface ApiMenuMapper extends BaseMapper<ApiMenu> { | |||
| List<ApiMenu> listApiMenu(ApiMenu apiMenu); | |||
| List<ApiMenu> listParentMenu(); | |||
| List<ApiMenuVO> listApiMenuAndDetail(ApiMenu apiMenu); | |||
| List<ListApiSubmenuVO> listSubmenu(Long id); | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.LevelPackage; | |||
| import java.util.List; | |||
| public interface LevelPackageMapper extends CommonMapper<LevelPackage, Long>{ | |||
| List<LevelPackage> findList(LevelPackage record); | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.ProjectPackageDetail; | |||
| import java.util.List; | |||
| public interface ProjectPackageDetailMapper extends CommonMapper<ProjectPackageDetail, Long>{ | |||
| List<ProjectPackageDetail> findList(ProjectPackageDetail record); | |||
| } | |||
| @@ -3,5 +3,21 @@ package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.sm.ServiceInfo; | |||
| import java.util.List; | |||
| /** | |||
| * 合作商service | |||
| * | |||
| * @author xmzhao71 | |||
| * @date 2023-10-24 | |||
| */ | |||
| public interface ServiceInfoMapper extends CommonMapper<ServiceInfo, Long> { | |||
| /** | |||
| * 全查询合作商 | |||
| * | |||
| * @param serviceInfo | |||
| * @return {@link List}<{@link ServiceInfo}> | |||
| */ | |||
| List<ServiceInfo> listServiceInfo(ServiceInfo serviceInfo); | |||
| } | |||
| @@ -0,0 +1,12 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.UserLevelPackage; | |||
| import java.util.List; | |||
| public interface UserLevelPackageMapper extends CommonMapper<UserLevelPackage, Long>{ | |||
| List<UserLevelPackage> findList(UserLevelPackage record); | |||
| } | |||
| @@ -9,4 +9,11 @@ public interface WxThirdPartyApiMapper extends CommonMapper<WxThirdPartyApi, Lon | |||
| List<WxThirdPartyApi> findList(WxThirdPartyApi apiConfig); | |||
| /** | |||
| * 全查询秘钥 | |||
| * | |||
| * @param thirdPartyApi | |||
| * @return {@link List}<{@link WxThirdPartyApi}> | |||
| */ | |||
| List<WxThirdPartyApi> listThirdPartyApi(WxThirdPartyApi thirdPartyApi); | |||
| } | |||
| @@ -52,15 +52,6 @@ public interface WxAppinfoService { | |||
| */ | |||
| WxAppinfo getById(Long id); | |||
| /** | |||
| * 多个存在获取集团的。 | |||
| * | |||
| * @param appId | |||
| * @return | |||
| */ | |||
| WxAppinfo getOnlyByAppId(String appId); | |||
| WxAppinfo getByAppId(String appId,String tenantId); | |||
| /** | |||
| * 获取c端小程序信息 | |||
| * @return | |||
| @@ -85,14 +76,15 @@ public interface WxAppinfoService { | |||
| */ | |||
| void deleteById(Long id); | |||
| WxAppinfo getOnlyByAppIdFromRedis(String appId); | |||
| WxAppinfo getByAppIdFromRedis(String appId,String tenantId); | |||
| WxAppinfo getByIdFromRedis(Long id); | |||
| WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat appPlat); | |||
| WxAppinfo getProjectCAppInfo(Integer projectType, Integer plat); | |||
| WxAppinfo getProjectCAppInfoFromRedis(Integer projectType, Integer plat); | |||
| WxAppinfo getProjectCAppInfo(String appId, Integer projectType); | |||
| WxAppinfo getProjectCAppInfoFromRedis(String appId, Integer projectType); | |||
| } | |||
| @@ -5,5 +5,7 @@ import com.iformall.common.ResultData; | |||
| import java.util.Map; | |||
| public interface WxCUserAuthorityService { | |||
| Map<String,Object> getAuthor(Long id, String code, Integer type, Long resourceId); | |||
| } | |||
| @@ -8,7 +8,7 @@ import java.util.Map; | |||
| public interface WxCVideoService { | |||
| Map<String, Object> getById(Long id) throws Exception; | |||
| Map<String, Object> getById(Long userId) throws Exception; | |||
| WxCVideoTable selectOne(Long id, long resource_id); | |||
| } | |||
| @@ -8,9 +8,11 @@ import java.util.List; | |||
| import java.util.Map; | |||
| public interface WxCVoiceService { | |||
| Map<String,Object> getById(Long id,String phone); | |||
| Map<String,Object> getById(Long userId); | |||
| List<VoiceInfo> chooseType(Long id); | |||
| Map<String,Object> voicePreview(AiPreviewParam aiPreviewParam); | |||
| Map<String, Object> voicePreview(Long voiceId, String voiceStyle, String text, Integer speed); | |||
| } | |||
| @@ -1,70 +0,0 @@ | |||
| package com.iformall.service; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPayBill; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public interface WxPayBillService { | |||
| /** | |||
| * 创建支付订单 | |||
| * | |||
| * @param record 支付订单请求 | |||
| * @param payWay | |||
| * @return | |||
| */ | |||
| ResultData createPayBill(WxMerchant merchant,Integer billTypeValue,WxAppinfo appInfo, WxPayBill record, EnumPayWay payWay); | |||
| /** | |||
| * 微信支付订单查询 | |||
| * @param appInfo 支付订单Appinfo | |||
| * @param record 支付订单 | |||
| */ | |||
| ResultData payBillQuery(WxAppinfo appInfo, WxPayBill record); | |||
| /** | |||
| * 微信支付关闭订单 | |||
| * @param appInfo 支付订单Appinfo | |||
| * @param record 支付订单 | |||
| */ | |||
| ResultData payBillClose(WxAppinfo appInfo, WxPayBill record); | |||
| /** | |||
| * 异步通知 | |||
| * | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| String notify(String tenantId,Map<String, String> paramMap, EnumPayWay payWay); | |||
| /** | |||
| * 支付成功处理 | |||
| * | |||
| * @param record | |||
| * @param transactionId | |||
| */ | |||
| void handleBillPaySuccess(WxPayBill record, String transactionId); | |||
| /** | |||
| * 支付状态处理 | |||
| * | |||
| * @param record | |||
| */ | |||
| void handlePayBillStatusUpdate(WxPayBill record); | |||
| WxPayBill getById(Long payBillId); | |||
| void updatePayBillStatus(WxPayBill payBill); | |||
| WxPayBill queryPayBill(WxPayBill payBill); | |||
| } | |||
| @@ -41,13 +41,6 @@ public interface WxRefundOrderService { | |||
| * @return | |||
| */ | |||
| ResultData queryRefundOrder(WxAppinfo appInfo, WxRefundOrder record); | |||
| /** | |||
| * 异步通知 | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| String notify(Map<String, String> paramMap, EnumPayWay payWay,EnumPayVersion payVersion); | |||
| /** | |||
| * 处理退款成功 | |||
| @@ -1,5 +1,8 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.dto.sm.SaveThirdPartyApiDTO; | |||
| import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | |||
| import com.iformall.domain.po.WxThirdPartyApi; | |||
| import java.util.List; | |||
| @@ -18,4 +21,29 @@ public interface WxThirdPartyApiService { | |||
| WxThirdPartyApi findByApp(String appId, String appKey); | |||
| /** | |||
| * 分页查询秘钥 | |||
| * | |||
| * @param thirdPartyApi | |||
| * @param pageNum | |||
| * @param pageSize | |||
| * @return {@link PageInfo}<{@link WxThirdPartyApi}> | |||
| */ | |||
| PageInfo<WxThirdPartyApi> pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize); | |||
| /** | |||
| * 新增秘钥 | |||
| * | |||
| * @param dto | |||
| */ | |||
| void saveThirdPartyApi(SaveThirdPartyApiDTO dto); | |||
| /** | |||
| * 修改秘钥状态 | |||
| * | |||
| * @param dto | |||
| */ | |||
| void updateThirdPartyApiStatus(UpdateThirdPartyApiStatusDTO dto); | |||
| WxThirdPartyApi getThirdPartyApi(Long id); | |||
| } | |||
| @@ -15,6 +15,7 @@ import com.iformall.service.WxMallService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -93,30 +94,6 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public WxAppinfo getOnlyByAppId(String appId) { | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setAppId(appId); | |||
| List<WxAppinfo> list = wxAppinfoMapper.findList(appinfoQ); | |||
| if(list.size() == 1){ | |||
| return list.get(0); | |||
| }else if(list.size() > 0){ | |||
| for (WxAppinfo appinfo:list) { | |||
| TenantEntity tenantEntity = new TenantEntity(); | |||
| tenantEntity.setTenantId(appinfo.getTenantId()); | |||
| if(wxMallService.isgroupSupport(tenantEntity)){ | |||
| return appinfo; | |||
| } | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public WxAppinfo getByAppId(String appId, String tenantId) { | |||
| return wxAppinfoMapper.findByAppId(appId,tenantId); | |||
| } | |||
| @Override | |||
| public void wxAppinfoInit(String tenantId, Long payId, Long payBillId, WxProjectConfig wxProjectConfig) { | |||
| @@ -174,48 +151,6 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||
| wxAppinfoMapper.deleteById(id); | |||
| } | |||
| @Override | |||
| public WxAppinfo getOnlyByAppIdFromRedis(String appId) { | |||
| WxAppinfo record = null; | |||
| String key = Constant.appinfoPrev + "only" + ":" + appId; | |||
| record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); | |||
| if (null == record) { | |||
| record = this.getOnlyByAppId(appId); | |||
| if(record != null){ | |||
| RedisCacheUtils.cache(wxAppinfoRedisTemplate, key, record, 3600*24*7); | |||
| } | |||
| } | |||
| return record; | |||
| } | |||
| @Override | |||
| public WxAppinfo getByAppIdFromRedis(String appId,String tenantId) { | |||
| WxAppinfo record = null; | |||
| String key = Constant.appinfoPrev + tenantId + ":" + appId; | |||
| record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); | |||
| if (null == record) { | |||
| record = this.getByAppId(appId,tenantId); | |||
| if(record != null){ | |||
| RedisCacheUtils.cache(wxAppinfoRedisTemplate, key, record, 3600*24*7); | |||
| } | |||
| } | |||
| return record; | |||
| } | |||
| @Override | |||
| public WxAppinfo getByIdFromRedis(Long id) { | |||
| WxAppinfo record = null; | |||
| String key = Constant.appinfoPrev + id; | |||
| record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); | |||
| if (null == record) { | |||
| record = this.getById(id); | |||
| if(record != null){ | |||
| RedisCacheUtils.cache(wxAppinfoRedisTemplate, key, record, 3600*24*7); | |||
| } | |||
| } | |||
| return record; | |||
| } | |||
| @Override | |||
| public WxAppinfo getCAppInfoFromRedis(String tenantId, EnumAppPlat plat) { | |||
| WxAppinfo record = null; | |||
| @@ -267,19 +202,48 @@ public class WxAppinfoServiceImpl implements WxAppinfoService { | |||
| return record; | |||
| } | |||
| @Override | |||
| public WxAppinfo getProjectCAppInfo(String appId, Integer projectType) { | |||
| if(StringUtils.isBlank(appId) || projectType == null){ | |||
| return null; | |||
| } | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setProjectType(projectType); | |||
| appinfoQ.setAppId(appId); | |||
| appinfoQ.setType(EnumAppType.C.getCode()); | |||
| WxAppinfo appInfo = wxAppinfoMapper.selectOne(new QueryWrapper<>(appinfoQ)); | |||
| return appInfo; | |||
| } | |||
| @Override | |||
| public WxAppinfo getProjectCAppInfoFromRedis(String appId, Integer projectType) { | |||
| if(StringUtils.isBlank(appId) || projectType == null){ | |||
| return null; | |||
| } | |||
| WxAppinfo record = null; | |||
| String key = Constant.appinfoPrev + appId + "-" + projectType | |||
| + "-" + EnumAppType.C.getCode(); | |||
| record = RedisCacheUtils.getCacheObject(wxAppinfoRedisTemplate, key, WxAppinfo.class); | |||
| if (null == record) { | |||
| record = this.getProjectCAppInfo(appId, projectType); | |||
| if(record != null){ | |||
| RedisCacheUtils.cache(wxAppinfoRedisTemplate, key, record, 3600*24*7); | |||
| } | |||
| } | |||
| return record; | |||
| } | |||
| private void deleteRedis(Long id){ | |||
| WxAppinfo record = this.getById(id); | |||
| if(record != null){ | |||
| String key1 = Constant.appinfoPrev + record.getAppId(); | |||
| String key1 = Constant.appinfoPrev + record.getId(); | |||
| RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key1); | |||
| String key2 = Constant.appinfoPrev + record.getId(); | |||
| String key2 = Constant.appinfoPrev + record.getProjectType() + "-" + record.getPlat() | |||
| + "-" + EnumAppType.C.getCode(); | |||
| RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key2); | |||
| String key3 = Constant.appinfoPrev + record.getTenantId() | |||
| + "-" + EnumAppPlat.getByCode(record.getPlat()) + "-" + record.getType(); | |||
| String key3 = Constant.appinfoPrev + record.getAppId() + "-" + record.getProjectType() | |||
| + "-" + EnumAppType.C.getCode(); | |||
| RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key3); | |||
| String key4 = Constant.appinfoPrev + record.getTenantId() | |||
| + "-" + null + "-" + record.getType(); | |||
| RedisCacheUtils.removeCache(wxAppinfoRedisTemplate, key4); | |||
| } | |||
| } | |||
| @@ -19,8 +19,9 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { | |||
| @Override | |||
| public Map<String, Object> getAuthor(Long id, String code, Integer type, Long resourceId) { | |||
| List<WxCUserAuthority> resultList = new ArrayList<WxCUserAuthority>(); | |||
| HashMap<String, Object> authorVos = new HashMap<>(); | |||
| List<WxCUserAuthority> resultList = new ArrayList<WxCUserAuthority>(); | |||
| if (type == 0) { | |||
| //查询数字人相关权限 | |||
| @@ -31,41 +32,9 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { | |||
| resultList = wxCUserAuthorityMapper.getAuthorVoice(id, 1, resourceId); | |||
| } | |||
| if (resourceId == null || resourceId == -1) { | |||
| //若资源id没有传入那就展示所有当前类型资源权限 | |||
| HashMap<String, Object> info = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| List authorList = new ArrayList(); | |||
| for (WxCUserAuthority wxCUserAuthority : resultList) { | |||
| HashMap<String, Object> data = new HashMap<>(); | |||
| data.put("username", wxCUserAuthority.getUserName()); | |||
| data.put("type", wxCUserAuthority.getType()); | |||
| data.put("resource_id", wxCUserAuthority.getResourceId()); | |||
| data.put("class", wxCUserAuthority.getClassType()); | |||
| data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | |||
| data.put("expire_time", wxCUserAuthority.getExpireTime().getTime() / 1000); | |||
| authorList.add(data); | |||
| } | |||
| authorVos.put("authorList", authorList); | |||
| info.put("log_id", id); | |||
| info.put("server_type", "author"); | |||
| authorVos.put("info", info); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| authorVos.put("status", status); | |||
| return authorVos; | |||
| } | |||
| HashMap<String, Object> data = new HashMap<>(); | |||
| HashMap<String, Object> info = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| if (resultList.size() == 0) { | |||
| status.put("code", 5001); | |||
| status.put("msg", "没有该资源的权限"); | |||
| authorVos.put("status", status); | |||
| return authorVos; | |||
| } | |||
| for (WxCUserAuthority wxCUserAuthority : resultList) { | |||
| data.put("username", wxCUserAuthority.getUserName()); | |||
| if (resultList.size() == 1) { | |||
| HashMap<String, Object> data = new HashMap<>(); | |||
| WxCUserAuthority wxCUserAuthority = resultList.get(0); | |||
| data.put("type", wxCUserAuthority.getType()); | |||
| data.put("resource_id", wxCUserAuthority.getResourceId()); | |||
| @@ -75,14 +44,8 @@ public class WxCUserAuthorityServiceImpl implements WxCUserAuthorityService { | |||
| data.put("class", EnumClassType.SHARE.getCode()); | |||
| data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | |||
| data.put("expire_time", wxCUserAuthority.getExpireTime().getTime() / 1000); | |||
| return data; | |||
| } | |||
| authorVos.put("data", data); | |||
| info.put("log_id", id); | |||
| info.put("server_type", "author"); | |||
| authorVos.put("info", info); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| authorVos.put("status", status); | |||
| return authorVos; | |||
| return null; | |||
| } | |||
| } | |||
| @@ -39,13 +39,12 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer | |||
| WxCVideoMapper wxCVideoMapper; | |||
| @Override | |||
| public Map<String, Object> getById(Long id) { | |||
| List<WxCVideoTable> TemplateVideo = wxCVideoMapper.getById(id); | |||
| Map<String, Object> avatarVos = new HashMap(); | |||
| public Map<String, Object> getById(Long userId) { | |||
| Map<String, Object> data = new HashMap(); | |||
| List<WxCVideoTable> TemplateVideo = wxCVideoMapper.getById(userId); | |||
| List authorlist = new ArrayList(); | |||
| for (WxCVideoTable wxCVideoTable : TemplateVideo) { | |||
| data.put("username", wxCVideoTable.getUserName()); | |||
| data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | |||
| Map<String, Object> avatar = new HashMap(); | |||
| @@ -63,7 +62,6 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer | |||
| avatar.put("avatar_model_md5", wxCVideoTable.getModelMd5()); | |||
| } | |||
| try { | |||
| File preinfoFile = new File(wxCVideoTable.getPreInfoPath()); | |||
| avatar.put("avatar_preinfo_md5", getFileMD5(preinfoFile)); | |||
| @@ -75,19 +73,10 @@ public class WxCVideoServiceImpl implements WxCVideoService, IExcelExportServer | |||
| avatar.put("expire_time", wxCVideoTable.getExpireTime().getTime() / 1000); | |||
| avatar.put("class", wxCVideoTable.getClassType()); | |||
| authorlist.add(avatar); | |||
| data.put("authorlist", authorlist); | |||
| } | |||
| avatarVos.put("data", data); | |||
| Map<String, Object> info = new HashMap(); | |||
| Map<String, Object> status = new HashMap(); | |||
| info.put("log_id", id); | |||
| info.put("server_type", "avatar list"); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| avatarVos.put("info", info); | |||
| avatarVos.put("status", status); | |||
| return avatarVos; | |||
| data.put("authorlist", authorlist); | |||
| return data; | |||
| } | |||
| @Override | |||
| @@ -17,9 +17,12 @@ import com.iformall.mapper.WxCVoiceMapper; | |||
| import com.iformall.service.WxCVoiceService; | |||
| import com.iformall.sm.AiPreviewParam; | |||
| import com.iformall.sm.AiPreviewResult; | |||
| import com.iformall.sm.AiTtsHelper; | |||
| import com.iformall.sm.AiVideoHelper; | |||
| import com.iformall.utils.Constant; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.util.ObjectUtils; | |||
| @@ -28,6 +31,7 @@ import java.util.*; | |||
| @Service | |||
| public class WxCVoiceServiceImpl implements WxCVoiceService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxCVoiceMapper wxCVoiceMapper; | |||
| @@ -43,11 +47,10 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||
| @Override | |||
| public Map<String, Object> getById(Long id,String phone) { | |||
| List<WxCVoiceTable> resultList = wxCVoiceMapper.getById(id); | |||
| HashMap<String, Object> result = new HashMap<>(); | |||
| public Map<String, Object> getById(Long userId) { | |||
| HashMap<String, Object> data = new HashMap<>(); | |||
| data.put("username", phone); | |||
| List<WxCVoiceTable> resultList = wxCVoiceMapper.getById(userId); | |||
| data.put("current_time", new Date(System.currentTimeMillis() / 1000)); | |||
| // List audioList = new ArrayList(); | |||
| Map<Long,Map<String, Object>> audioList = new HashMap(); | |||
| @@ -102,44 +105,10 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||
| } | |||
| data.put("audioList", new ArrayList<>(audioList.values())); | |||
| result.put("data", data); | |||
| HashMap<String, Object> info = new HashMap<>(); | |||
| HashMap<String, Object> status = new HashMap<>(); | |||
| info.put("log_id", id); | |||
| info.put("server_type", "audio list"); | |||
| result.put("info", info); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| result.put("status", status); | |||
| return result; | |||
| } | |||
| @Override | |||
| public Map<String, Object> voicePreview(AiPreviewParam aiPreviewParam) { | |||
| VoiceInfo voiceInfo = voiceMapper.selectOne(new LambdaQueryWrapper<VoiceInfo>().eq(VoiceInfo::getIsDel, 0).eq(VoiceInfo::getId, aiPreviewParam.getVoice_id())); | |||
| if (ObjectUtils.isEmpty(voiceInfo)) { | |||
| Map<String, Object> status = new HashMap<>(); | |||
| status.put("code", ErrorCode.SYS_SERVER_ERROR.getCode()); | |||
| status.put("msg", "声音信息不存在"); | |||
| return status; | |||
| } | |||
| AiPreviewParam param = new AiPreviewParam(); | |||
| param.setGen_txt(aiPreviewParam.getGen_txt().replaceAll(Constant.text_pause, "[*]")); | |||
| param.setVoice_id(voiceInfo.getMouldSmId()); | |||
| param.setVoice_style(StringUtils.isBlank(aiPreviewParam.getVoice_style()) ? EnumSpeakType.default_0.getMessage() : aiPreviewParam.getVoice_style()); | |||
| param.setGender(voiceInfo.getSex() == 1 ? "male" : "female"); | |||
| AiPreviewResult result = AiVideoHelper.voicePreview(param); | |||
| Map<String, Object> resultMap = new HashMap<>(); | |||
| Map<String, Object> data = new HashMap<>(); | |||
| data.put("ttsurl", result.getUrl()); | |||
| Map<String, Object> status = new HashMap<>(); | |||
| status.put("code", 1000); | |||
| status.put("msg", "success"); | |||
| resultMap.put("data", data); | |||
| resultMap.put("status", status); | |||
| return resultMap; | |||
| return data; | |||
| } | |||
| @Override | |||
| public List<VoiceInfo> chooseType(Long id) { | |||
| List<VoiceInfo> voiceInfos = voiceMapper.selectList( | |||
| @@ -173,4 +142,27 @@ public class WxCVoiceServiceImpl implements WxCVoiceService { | |||
| }); | |||
| return voiceInfos; | |||
| } | |||
| @Override | |||
| public Map<String, Object> voicePreview(Long voiceId, String voiceStyle, String text, Integer speed) { | |||
| VoiceInfo voiceInfo = voiceMapper.selectById(voiceId); | |||
| if(voiceInfo == null){ | |||
| logger.error("未查询到声音{}"+voiceId); | |||
| return null; | |||
| } | |||
| AiPreviewParam param = new AiPreviewParam(); | |||
| param.setVoice_id(voiceInfo.getMouldSmId()); | |||
| param.setVoice_style(StringUtils.isBlank(voiceStyle) ? EnumSpeakType.default_0.getMessage() : voiceStyle); | |||
| param.setGen_txt(text.replaceAll(Constant.text_pause, "[*]")); | |||
| param.setSpeed(speed==null?100:speed); | |||
| AiPreviewResult aiTtsResult = AiTtsHelper.voicePreview(param); | |||
| if(!aiTtsResult.isSuccess()){ | |||
| logger.error("tts 预览失败{}"+aiTtsResult.getMsg()); | |||
| return null; | |||
| } | |||
| Map<String, Object> data = new HashMap<>(); | |||
| data.put("ttsurl", aiTtsResult.getUrl()); | |||
| return data; | |||
| } | |||
| } | |||
| @@ -1,882 +0,0 @@ | |||
| package com.iformall.service.impl; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxBillSettle; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayAccountBill; | |||
| import com.iformall.domain.po.WxPayBill; | |||
| import com.iformall.domain.vo.WxBillAll; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.pay.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.utils.*; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.text.ParseException; | |||
| import java.util.*; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @Service | |||
| public class WxPayBillServiceImpl implements WxPayBillService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| WxPayAccountBillMapper wxPayAccountBillMapper; | |||
| @Autowired | |||
| WxPayAccountService wxPayAccountService; | |||
| @Autowired | |||
| WxPayBillMapper wxPayBillMapper; | |||
| @Autowired | |||
| WxBillAllMapper wxBillAllMapper; | |||
| @Lazy | |||
| @Autowired | |||
| WxBillAllService wxBillAllService; | |||
| @Autowired | |||
| WxMerchantBUserMapper wxMerchantBUserMapper; | |||
| @Lazy | |||
| @Autowired | |||
| private WxBillSettleService wxBillSettleService; | |||
| @Lazy | |||
| @Autowired | |||
| WxMerchantBUserService wxMerchantBUserService; | |||
| @Lazy | |||
| @Autowired | |||
| WxMerchantService wxMerchantService; | |||
| JSONObject errorMap = JSON.parseObject("{" + | |||
| "\"NOAUTH\":{\"detail\":\"商户无此接口权限\",\"reason\":\"商户未开通此接口权限\",\"resolution\":\"请商户前往申请此接口权限\"}," + | |||
| "\"NOTENOUGH\":{\"detail\":\"余额不足\",\"reason\":\"用户帐号余额不足\",\"resolution\":\"用户帐号余额不足,请用户充值或更换支付卡后再支付\"}," + | |||
| "\"ORDERPAID\":{\"detail\":\"商户订单已支付\",\"reason\":\"商户订单已支付,无需重复操作\",\"resolution\":\"商户订单已支付,无需更多操作\"}," + | |||
| "\"ORDERCLOSED\":{\"detail\":\"订单已关闭\",\"reason\":\"当前订单已关闭,无法支付\",\"resolution\":\"当前订单已关闭,请重新下单\"}," + | |||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\t\",\"reason\":\"系统超时\",\"resolution\":\"系统异常,请用相同参数重新调用\"}," + | |||
| "\"APPID_NOT_EXIST\":{\"detail\":\"APPID不存在\",\"reason\":\"参数中缺少APPID\",\"resolution\":\"请检查APPID是否正确\"}," + | |||
| "\"MCHID_NOT_EXIST\":{\"detail\":\"MCHID不存在\",\"reason\":\"参数中缺少MCHID\",\"resolution\":\"请检查MCHID是否正确\"}," + | |||
| "\"APPID_MCHID_NOT_MATCH\":{\"detail\":\"appid和mch_id不匹配\",\"reason\":\"appid和mch_id不匹配\",\"resolution\":\"请确认appid和mch_id是否匹配\"}," + | |||
| "\"LACK_PARAMS\":{\"detail\":\"缺少参数\t\",\"reason\":\"缺少必要的请求参数\",\"resolution\":\"请检查参数是否齐全\"}," + | |||
| "\"OUT_TRADE_NO_USED\":{\"detail\":\"商户订单号重复\",\"reason\":\"同一笔交易不能多次提交\",\"resolution\":\"请核实商户订单号是否重复提交\"}," + | |||
| "\"SIGNERROR\":{\"detail\":\"签名错误\",\"reason\":\"参数签名结果不正确\",\"resolution\":\"请检查签名参数和方法是否都符合签名算法要求\"}," + | |||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"resolution\":\"请检查XML参数格式是否正确\"}," + | |||
| "\"REQUIRE_POST_METHOD\":{\"detail\":\"请使用post方法\",\"reason\":\"未使用post传递参数\",\"resolution\":\"请检查请求参数是否通过post方法提交\"}," + | |||
| "\"POST_DATA_EMPTY\":{\"detail\":\"post数据为空\",\"reason\":\"post数据不能为空\",\"resolution\":\"请检查post数据是否为空\"}," + | |||
| "\"NOT_UTF8\":{\"detail\":\"编码格式错误\",\"reason\":\"未使用指定编码格式\",\"resolution\":\"请使用UTF-8编码格式\"}}"); | |||
| JSONObject errorMapQuery = JSON.parseObject("{" + | |||
| "\"ORDERNOTEXIST\":{\"detail\":\"此交易订单号不存在\",\"reason\":\"查询系统中不存在此交易订单号\",\"resolution\":\"该API只能查提交支付交易返回成功的订单,请商户检查需要查询的订单号是否正确\"},\n" + | |||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\t\",\"reason\":\"后台系统返回错误\",\"resolution\":\"系统异常,请再调用发起查询\"}}"); | |||
| JSONObject errorMapClose = JSON.parseObject("{" + | |||
| "\"ORDERPAID\":{\"detail\":\"订单已支付\",\"reason\":\"订单已支付,不能发起关单\",\"resolution\":\"订单已支付,不能发起关单,请当作已支付的正常交易\"}," + | |||
| "\"SYSTEMERROR\":{\"detail\":\"系统错误\",\"reason\":\"系统错误\",\"resolution\":\"系统异常,请重新调用该API\"}," + | |||
| "\"ORDERCLOSED\":{\"detail\":\"订单已关闭\",\"reason\":\"订单已关闭,无法重复关闭\",\"resolution\":\"订单已关闭,无需继续调用\"}," + | |||
| "\"SIGNERROR\":{\"detail\":\"签名错误\",\"reason\":\"参数签名结果不正确\",\"resolution\":\"请检查签名参数和方法是否都符合签名算法要求\"}," + | |||
| "\"REQUIRE_POST_METHOD\":{\"detail\":\"请使用post方法\",\"reason\":\"未使用post传递参数\",\"resolution\":\"请检查请求参数是否通过post方法提交\"}," + | |||
| "\"XML_FORMAT_ERROR\":{\"detail\":\"XML格式错误\t\",\"reason\":\"XML格式错误\",\"reason\":\"请检查XML参数格式是否正确\"}}"); | |||
| @Override | |||
| public ResultData createPayBill(WxMerchant merchant,Integer billTypeValue,WxAppinfo appInfo, WxPayBill record, EnumPayWay payWay) { | |||
| final IdWorker idworker = IdWorker.get(); | |||
| EnumPayShare isShare = EnumPayShare.NO; | |||
| try { | |||
| //查询账单是否存在 | |||
| WxBillAll wxBillAll = new WxBillAll(); | |||
| wxBillAll.updateTenantInfo(record); | |||
| wxBillAll.setId(record.getBillId()); | |||
| wxBillAll.setBillTypeValue(billTypeValue); | |||
| List<Map<String, Object>> bills = wxBillAllService.listBill(wxBillAll,merchant,true,false,false,false); | |||
| if (bills.size()==0) { | |||
| logger.error("pay bill, bill not allow, repaymentReq: " + JSONObject.toJSONString(record) + ", payWay: " + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.BILL_ROUTINE_IS_NOT_FOUND); | |||
| } | |||
| //获取账单数据 | |||
| Map<String, Object> bill = bills.get(0); | |||
| Long owe = (Long) bill.get("owe"); | |||
| if (owe.longValue() <= 0) { | |||
| logger.info("账单欠缴为0"); | |||
| return new ResultData(ErrorCode.BILL_OWE_ZERO); | |||
| } | |||
| //获取支付账户信息 | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||
| Date currentDate = new Date(); | |||
| String payBillNo; | |||
| WxPayBill billParam= new WxPayBill(); | |||
| billParam.setBillId(record.getBillId()); | |||
| List<WxPayBill> list = wxPayBillMapper.findList(billParam); | |||
| //数据库不存在已有订单,新建订单 | |||
| if (list.size() <= 0) { | |||
| // 创建支付订单 | |||
| Long id = idworker.nextId(); | |||
| payBillNo = id+DateUtils.getSystemTime("yyMMddHHmmss"); | |||
| record.setId(id); | |||
| record.updateTenantInfo(record); | |||
| record.setbUserId(record.getbUserId()); | |||
| record.setCreateTime(currentDate); | |||
| record.setUpdateTime(currentDate); | |||
| record.setPayTimeStart(currentDate); | |||
| long endtime = currentDate.getTime() + 120 * 60 * 1000; | |||
| record.setPayTimeEnd(new Date(endtime)); | |||
| // 支付单号 | |||
| record.setPayBillNo(payBillNo); | |||
| record.setPayAmount((Long) bill.get("owe")); | |||
| record.setPayVendor(payWay.getCode()); | |||
| record.setPayBillStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | |||
| record.setShare(isShare.getCode()); | |||
| record.setBillTypeValue(billTypeValue); | |||
| int sqlRow = wxPayBillMapper.insert(record); | |||
| if (sqlRow != 1) { | |||
| logger.error("pay bill insert error: " + JSONObject.toJSONString(record)); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| logger.info("创建支付订单:"+record.toString()); | |||
| } else { | |||
| //数据库存在订单信息,更新支付中状态,返回之前的预支付信息 | |||
| WxPayBill wxPayBill = list.get(0); | |||
| wxPayBill.setShare(isShare.getCode()); | |||
| //更新订单状态为支付中 | |||
| wxPayBill.setPayBillStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | |||
| wxPayBill.setUpdateTime(currentDate); | |||
| int sqlRow = wxPayBillMapper.updateById(wxPayBill); | |||
| if (sqlRow != 1) { | |||
| logger.error("pay bill update error: " + wxPayBill.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| //数据库中openId与再次传来的openId不相同那么关闭此订单再次生成新的订单 | |||
| if(!wxPayBill.getOpenId().equals(record.getOpenId())){ | |||
| String openId = record.getOpenId(); | |||
| //关闭订单 | |||
| logger.info("openId不同时关闭之前的订单:"+record.toString()); | |||
| ResultData resultData = payBillClose(appInfo, wxPayBill); | |||
| if(resultData.code!=Result.SUCCESS){ | |||
| return new ResultData(ErrorCode.ORDER_IS_FAIL); | |||
| } | |||
| record = wxPayBillMapper.selectById(wxPayBill.getId()); | |||
| record.setOpenId(openId); | |||
| //创建新的订单号 | |||
| payBillNo = record.getId()+DateUtils.getSystemTime("yyMMddHHmmss"); | |||
| record.setPayTimeStart(currentDate); | |||
| long endtime = currentDate.getTime() + 120 * 60 * 1000; | |||
| record.setPayTimeEnd(new Date(endtime)); | |||
| record.setPayBillNo(payBillNo); | |||
| record.setPayAmount((Long) bill.get("owe")); | |||
| record.setUpdateTime(currentDate); | |||
| sqlRow = wxPayBillMapper.updateById(record); | |||
| if (sqlRow != 1) { | |||
| logger.error("pay bill update error: " + JSONObject.toJSONString(record)); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| logger.info("新的订单数据:"+JSONObject.toJSONString(record)); | |||
| }else{ | |||
| logger.info("数据库存在订单信息,更新支付中状态,返回之前的预支付信息:"+JSONObject.toJSONString(wxPayBill)); | |||
| if (!owe.equals(wxPayBill.getPayAmount())) { | |||
| logger.info("欠缴费用与之前不同发起新的订单:" + wxPayBill.toString()); | |||
| ResultData resultData = payBillClose(appInfo, wxPayBill); | |||
| if (resultData.code != Result.SUCCESS) { | |||
| return new ResultData(ErrorCode.ORDER_IS_FAIL); | |||
| } | |||
| record = wxPayBillMapper.selectById(wxPayBill.getId()); | |||
| //创建新的订单号 | |||
| payBillNo = record.getId() + DateUtils.getSystemTime("yyMMddHHmmss"); | |||
| record.setPayTimeStart(currentDate); | |||
| long endtime = currentDate.getTime() + 120 * 60 * 1000; | |||
| record.setPayTimeEnd(new Date(endtime)); | |||
| record.setPayBillNo(payBillNo); | |||
| record.setPayAmount((Long) bill.get("owe")); | |||
| record.setUpdateTime(currentDate); | |||
| sqlRow = wxPayBillMapper.updateById(record); | |||
| if (sqlRow != 1) { | |||
| logger.error("pay bill update error: " + JSONObject.toJSONString(record)); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| logger.info("新的订单数据:" + JSONObject.toJSONString(record)); | |||
| } else if (wxPayBill.getPayTimeEnd().after(new Date())) { | |||
| //订单在120分钟之内没有失效,延用之前预支付订单号 | |||
| String noncestr = Utility.generate32UUID(); | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", appInfo.getAppId()); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + wxPayBill.getPrepayId()); | |||
| sighMap.put("signType", "HMAC-SHA256"); | |||
| String signAgent = WxPayment.createSignHMAC(sighMap, payAccount.getApiKey()); | |||
| Map<String,String> returnMap=new HashMap<>(); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + wxPayBill.getPrepayId()); | |||
| returnMap.put("paySign", signAgent); | |||
| returnMap.put("signType", "HMAC-SHA256"); | |||
| logger.info("订单在120分钟之内没有失效,延用之前预支付订单号:"+JSONObject.toJSONString(wxPayBill)); | |||
| return new ResultData(Result.SUCCESS, "创建支付订单成功", returnMap); | |||
| } else { | |||
| //超过时间关闭订单 | |||
| logger.info("超过时间关闭订单:" + wxPayBill.toString()); | |||
| ResultData resultData = payBillClose(appInfo, wxPayBill); | |||
| if(resultData.code!=Result.SUCCESS){ | |||
| return new ResultData(ErrorCode.ORDER_IS_FAIL); | |||
| } | |||
| record = wxPayBillMapper.selectById(wxPayBill.getId()); | |||
| //创建新的订单号 | |||
| payBillNo = record.getId()+DateUtils.getSystemTime("yyMMddHHmmss"); | |||
| record.setPayTimeStart(currentDate); | |||
| long endtime = currentDate.getTime() + 120 * 60 * 1000; | |||
| record.setPayTimeEnd(new Date(endtime)); | |||
| record.setPayBillNo(payBillNo); | |||
| record.setPayAmount((Long) bill.get("owe")); | |||
| record.setUpdateTime(currentDate); | |||
| sqlRow = wxPayBillMapper.updateById(record); | |||
| if (sqlRow != 1) { | |||
| logger.error("pay bill update error: " + JSONObject.toJSONString(record)); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| logger.info("新的订单数据:"+JSONObject.toJSONString(record)); | |||
| } | |||
| } | |||
| } | |||
| // 统一下单 // 服务商模式 | |||
| String noncestr = Utility.generate32UUID(); | |||
| WxPayOrderSP wxPayBillSP = new WxPayOrderSP(); | |||
| wxPayBillSP.setSub_openid(record.getOpenId()); | |||
| wxPayBillSP.setAppid(appInfo.getParentAppId()); | |||
| wxPayBillSP.setMch_id(payAccount.getMchId()); | |||
| wxPayBillSP.setSub_appid(appInfo.getAppId()); | |||
| wxPayBillSP.setSub_mch_id(payAccount.getSubMchId()); | |||
| wxPayBillSP.setNonce_str(noncestr); | |||
| wxPayBillSP.setBody(bill.get("billType").toString()); | |||
| wxPayBillSP.setOut_trade_no(record.getPayBillNo()); | |||
| wxPayBillSP.setTotal_fee(bill.get("owe").toString()); | |||
| // 终端IP | |||
| wxPayBillSP.setSpbill_create_ip(record.getIp()); | |||
| wxPayBillSP.setNotify_url(payAccount.getPayNotifyUrl()); | |||
| // 终端类型 | |||
| wxPayBillSP.setTrade_type(WxPay.TradeType.JSAPI.name()); | |||
| // 订单ID | |||
| wxPayBillSP.setProduct_id(String.valueOf(bill.get("id").toString())); | |||
| wxPayBillSP.setTime_start(Utility.getDataFormatStringYYYYMMDDHHmmss(currentDate)); | |||
| wxPayBillSP.setTime_expire(Utility.getDataFormatStringYYYYMMDDHHmmss(record.getPayTimeEnd())); | |||
| wxPayBillSP.setSign_type("HMAC-SHA256"); | |||
| wxPayBillSP.setProfit_sharing(null); | |||
| if (isShare == EnumPayShare.YES) { | |||
| wxPayBillSP.setProfit_sharing("Y"); | |||
| } | |||
| Map<String, String> payBillMap = BeanUtils.toStringMap(wxPayBillSP); | |||
| wxPayBillSP.setSign(WxPayment.createSignHMAC(payBillMap, payAccount.getApiKey())); | |||
| String response = WxPay.pushOrder(BeanUtils.toStringMap(wxPayBillSP)); | |||
| logger.info("pay bill, wechat pushBill, " + wxPayBillSP.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| returnMap.put("payBillId", record.getId().toString()); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String prepay_id = returnMap.get("prepay_id"); | |||
| // update payBill with prepay_id | |||
| record.setPrepayId(prepay_id); | |||
| record.setUpdateTime(new Date()); | |||
| try { | |||
| wxPayBillMapper.updateById(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay bill update error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| String timestamp = String.valueOf(Utility.getCurrentTimeStamp()); | |||
| Map<String, String> sighMap = MapUtil.getOrderMap(); | |||
| sighMap.put("appId", appInfo.getAppId()); | |||
| sighMap.put("timeStamp", timestamp); | |||
| sighMap.put("nonceStr", noncestr); | |||
| sighMap.put("package", "prepay_id=" + prepay_id); | |||
| sighMap.put("signType", "HMAC-SHA256"); | |||
| String signAgent = WxPayment.createSignHMAC(sighMap, payAccount.getApiKey()); | |||
| returnMap.put("timeStamp", timestamp); | |||
| returnMap.put("nonceStr", noncestr); | |||
| returnMap.put("package", "prepay_id=" + prepay_id); | |||
| returnMap.put("paySign", signAgent); | |||
| returnMap.put("signType", "HMAC-SHA256"); | |||
| logger.info("back to UI: " + returnMap.toString()); | |||
| return new ResultData(Result.SUCCESS, "创建支付订单成功", returnMap); | |||
| } | |||
| return updatePayBill(record, returnMap, result_code); | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| private ResultData updatePayBill(WxPayBill record, Map<String, String> returnMap, String result_code) { | |||
| String errMsg = ""; | |||
| JSONObject errObj = errorMap.getJSONObject(result_code); | |||
| if (errObj != null) { | |||
| errMsg = errObj.toJSONString(); | |||
| record.setFailReason(errMsg); | |||
| } else { | |||
| errMsg = returnMap.get("return_msg"); | |||
| record.setFailReason(errMsg); | |||
| } | |||
| record.setUpdateTime(new Date()); | |||
| try { | |||
| wxPayBillMapper.updateById(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay bill update error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||
| } | |||
| private String wechatPayBillQuery(WxAppinfo appInfo, WxPayBill record) { | |||
| // get payAccount | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||
| if (payAccount.getType().equals(EnumPayMode.MCH.getCode())) { | |||
| // 普通商户号模式 | |||
| WxPayOrderQ payBillQ = new WxPayOrderQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payBillQ.setAppid(appInfo.getAppId()); | |||
| payBillQ.setMch_id(payAccount.getMchId()); | |||
| payBillQ.setNonce_str(noncestr); | |||
| payBillQ.setOut_trade_no(record.getPayBillNo()); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payBillQ); | |||
| payBillQ.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payBillQ); | |||
| String response = WxPay.orderQuery(map); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } else { | |||
| // 服务商模式 | |||
| WxPayOrderSQ payBillSQ = new WxPayOrderSQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payBillSQ.setAppid(appInfo.getParentAppId()); | |||
| payBillSQ.setSub_appid(appInfo.getAppId()); | |||
| payBillSQ.setMch_id(payAccount.getMchId()); | |||
| payBillSQ.setSub_mch_id(payAccount.getSubMchId()); | |||
| payBillSQ.setNonce_str(noncestr); | |||
| payBillSQ.setOut_trade_no(record.getPayBillNo()); | |||
| payBillSQ.setSign_type("HMAC-SHA256"); | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payBillSQ); | |||
| payBillSQ.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payBillSQ); | |||
| String response = WxPay.orderQuery(map); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * 微信订单查询 | |||
| */ | |||
| @Override | |||
| public ResultData payBillQuery(WxAppinfo appInfo, WxPayBill record) { | |||
| try { | |||
| if (StringUtils.isBlank(record.getPayBillNo())) { | |||
| record.setPayBillNo(record.getPayBillNo()); | |||
| } | |||
| String response = wechatPayBillQuery(appInfo, record); | |||
| logger.info("pay bill query, " + record.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String trade_state = returnMap.get("trade_state"); | |||
| //SUCCESS—支付成功 | |||
| //REFUND—转入退款 | |||
| //NOTPAY—未支付 | |||
| //CLOSED—已关闭 | |||
| //REVOKED—已撤销(刷卡支付) | |||
| //USERPAYING--用户支付中 | |||
| //PAYERROR--支付失败(其他原因,如银行返回失败) | |||
| if ("SUCCESS".equals(trade_state)) { | |||
| record.setPayBillStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| handlePayBillStatusUpdate(record); | |||
| } else if ("USERPAYING".equals(trade_state)) { | |||
| record.setPayBillStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); | |||
| handlePayBillStatusUpdate(record); | |||
| } else { | |||
| record.setPayBillStatus(EnumPayStatus.PAY_STATUS_FAIL.getCode()); | |||
| handlePayBillStatusUpdate(record); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "订单查询成功", returnMap); | |||
| } else { | |||
| return updatePayBill(record, returnMap, result_code); | |||
| } | |||
| } catch (MallinkException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| private String wechatPayBillClose(WxAppinfo appInfo, WxPayBill record) { | |||
| // get payAccount | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appInfo.getPayId()); | |||
| if (payAccount.getType().equals(EnumPayMode.MCH.getCode())) { | |||
| // 普通商户号模式 | |||
| WxPayOrderQ payBillC = new WxPayOrderQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payBillC.setAppid(appInfo.getAppId()); | |||
| payBillC.setMch_id(payAccount.getMchId()); | |||
| payBillC.setNonce_str(noncestr); | |||
| payBillC.setOut_trade_no(record.getPayBillNo()); | |||
| return closeOrderNormal(payAccount, payBillC); | |||
| } else { | |||
| // 服务商模式 | |||
| WxPayOrderSQ payBillSC = new WxPayOrderSQ(); | |||
| String noncestr = Utility.generate32UUID(); | |||
| payBillSC.setAppid(appInfo.getParentAppId()); | |||
| payBillSC.setSub_appid(appInfo.getAppId()); | |||
| payBillSC.setMch_id(payAccount.getMchId()); | |||
| payBillSC.setSub_mch_id(payAccount.getSubMchId()); | |||
| payBillSC.setNonce_str(noncestr); | |||
| payBillSC.setOut_trade_no(record.getPayBillNo()); | |||
| payBillSC.setSign_type("HMAC-SHA256"); | |||
| return closeOrderServer(payAccount, payBillSC); | |||
| } | |||
| } | |||
| private String closeOrderServer(WxPayAccount payAccount, WxPayOrderSQ payBillSC) { | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payBillSC); | |||
| payBillSC.setSign(WxPayment.createSignHMAC(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payBillSC); | |||
| String response = WxPay.closeOrder(map); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| private String closeOrderNormal(WxPayAccount payAccount, WxPayOrderQ payBillC) { | |||
| try { | |||
| Map map = BeanUtils.toStringMap(payBillC); | |||
| payBillC.setSign(WxPayment.createSign(map, payAccount.getApiKey())); | |||
| map = BeanUtils.toStringMap(payBillC); | |||
| String response = WxPay.closeOrder(map); | |||
| return response; | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| /** | |||
| * 微信关闭支付订单 | |||
| */ | |||
| @Override | |||
| public ResultData payBillClose(WxAppinfo appInfo, WxPayBill record) { | |||
| try { | |||
| //关闭之前先查询 | |||
| ResultData resultData = payBillQuery(appInfo, record); | |||
| if(resultData.code == Result.SUCCESS) { | |||
| Map<String, String> map = (Map) resultData.data; | |||
| if("SUCCESS".equals(map.get("result_code")) && "SUCCESS".equals(map.get("trade_state"))){ | |||
| return new ResultData(ErrorCode.ORDER_HAD_PAY); | |||
| } | |||
| } | |||
| String response = wechatPayBillClose(appInfo, record); | |||
| logger.info("pay bill close, " + record.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| try { | |||
| record.setPayBillStatus(EnumPayStatus.PAY_STATUS_CANCEL.getCode()); | |||
| wxPayBillMapper.updateById(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay bill update error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| return new ResultData(Result.SUCCESS, "订单关闭成功", returnMap); | |||
| } else { | |||
| String errMsg = ""; | |||
| JSONObject errObj = errorMapClose.getJSONObject(result_code); | |||
| if (errObj != null) { | |||
| errMsg = errObj.toJSONString(); | |||
| } else { | |||
| errMsg = returnMap.get("return_msg"); | |||
| } | |||
| record.setFailReason(errMsg); | |||
| record.setUpdateTime(new Date()); | |||
| try { | |||
| wxPayBillMapper.updateById(record); | |||
| } catch (Exception e) { | |||
| logger.error("pay bill update error: " + record.toString()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR.getCode(), errMsg, returnMap); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| /** | |||
| * 提供微信支付回调调用 | |||
| * | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| @Override | |||
| public String notify(String tenantId,Map<String, String> paramMap, EnumPayWay payWay) { | |||
| // how to get wechatAppId, wechatMchId, partnerKey | |||
| logger.info("-------------"); | |||
| logger.info("微信回调返回值:" + JSONObject.toJSONString(paramMap)); | |||
| logger.info("-------------"); | |||
| String appId = paramMap.get("appid"); | |||
| String subAppId = paramMap.get("sub_appid"); | |||
| String mchId = paramMap.get("mch_id"); | |||
| String subMchId = paramMap.get("sub_mch_id"); | |||
| String attach = paramMap.get("attach"); | |||
| WxAppinfo appinfo; | |||
| boolean isNormal = true; | |||
| if (StringUtils.isBlank(subAppId) && StringUtils.isBlank(subMchId)) { | |||
| // 普通商户号 | |||
| appinfo = wxAppinfoService.getByAppIdFromRedis(appId,tenantId); | |||
| if (appinfo == null) { | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| isNormal = true; | |||
| } else { | |||
| // 服务号 现在用hmac-sha256 | |||
| appinfo = wxAppinfoService.getByAppIdFromRedis(subAppId,tenantId); | |||
| if (appinfo == null) { | |||
| throw new MallinkException(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| isNormal = false; | |||
| } | |||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); | |||
| if (payAccount == null) { | |||
| throw new MallinkException(ErrorCode.MCH_INFO_NOT_FOUND); | |||
| } | |||
| String partnerKey = payAccount.getApiKey(); | |||
| try { | |||
| if (payWay.getType() == EnumPayWay.EnumPayWayType.WX_MINIPAY) { | |||
| boolean signVerified = false; | |||
| if (isNormal) { | |||
| // 普通商户号支付 | |||
| signVerified = WxPayment.verifyNotify(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify bill, wxpay checksign error, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| } else { | |||
| // 服务号 现在用hmac-sha256 | |||
| signVerified = WxPayment.verifyNotifyHMAC(paramMap, partnerKey); | |||
| if (!signVerified) { | |||
| logger.warn("notify bill, wxpay checksign error, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOTIFY_CHECK_SIGN_ERROR); | |||
| } | |||
| } | |||
| if (!"SUCCESS".equals(paramMap.get("return_code"))) { | |||
| logger.warn("notify bill, wxpay status not success, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单状态码非SUCCESS"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| String payBillNo = paramMap.get("out_trade_no"); | |||
| String timEndStr = paramMap.get("time_end"); | |||
| Long payBillId = Long.valueOf(payBillNo.substring(0,payBillNo.length()-12)); | |||
| WxPayBill payBill = wxPayBillMapper.selectById(payBillId); | |||
| if (payBill == null) { | |||
| logger.warn("notify bill, wxpay check pay bill not exists, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单不存在"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| // 验证支付金额 | |||
| if (!paramMap.get("total_fee").equals(payBill.getPayAmount().toString())) { | |||
| logger.warn("notify bill, wxpay check total_fee is invalid, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "订单总金额不一致"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| Date timeEnd = null; | |||
| try { | |||
| timeEnd = Utility.getDateFromString(timEndStr); | |||
| } catch (ParseException e) { | |||
| logger.error("解析timeEnd失败"); | |||
| timeEnd = new Date(); | |||
| } | |||
| payBill.setPayTimeEnd(timeEnd); | |||
| // 处理支付成功 | |||
| handleBillPaySuccess(payBill, paramMap.get("transaction_id")); | |||
| logger.info("notify bill, wxpay checksign success, paramMap:{}, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString()); | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "SUCCESS"); | |||
| resultMap.put("return_msg", "OK"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| } catch (RuntimeException e) { | |||
| logger.warn("notify bill, checksign error, paramMap: " + paramMap.toString() + ", payWay:" + payWay.toString() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR); | |||
| } | |||
| SortedMap resultMap = new TreeMap(); | |||
| resultMap.put("return_code", "FAIL"); | |||
| resultMap.put("return_msg", "FAILED"); | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| @Override | |||
| public WxPayBill getById(Long id) { | |||
| return wxPayBillMapper.selectById(id); | |||
| } | |||
| @Override | |||
| public void updatePayBillStatus(WxPayBill payBill) { | |||
| try { | |||
| logger.info("更新支付订单"); | |||
| wxPayBillMapper.updateById(payBill); | |||
| }catch (MallinkException e){ | |||
| logger.info("更新支付订单失败"); | |||
| throw new MallinkException(ErrorCode.ORDER_UPDATE_ERR); | |||
| } | |||
| } | |||
| @Override | |||
| public WxPayBill queryPayBill(WxPayBill payBill) { | |||
| List<WxPayBill> select = wxPayBillMapper.selectList(new QueryWrapper(payBill)); | |||
| if(select.size()>0){ | |||
| return select.get(0); | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void handleBillPaySuccess(WxPayBill record, String transactionId) { | |||
| Date currentDate = new Date(); | |||
| EnumPayStatus payStatus = EnumPayStatus.getEnum(record.getPayBillStatus()); | |||
| // 判断支付状态 | |||
| if (payStatus == EnumPayStatus.PAY_STATUS_SUCCESS) { | |||
| // 已经是成功状态,只更新transactionId | |||
| try { | |||
| record.setUpdateTime(currentDate); | |||
| record.setTransactionId(transactionId); | |||
| wxPayBillMapper.updateById(record); | |||
| WxBillAll wxBillAll = new WxBillAll(); | |||
| wxBillAll.setId(record.getBillId()); | |||
| wxBillAll.setBillTypeValue(record.getBillTypeValue()); | |||
| WxMerchantBUser buser = wxMerchantBUserService.getById(record.getbUserId()); | |||
| WxMerchant wxMerchant = wxMerchantService.getById(buser.getMerchantId()); | |||
| List<Map<String, Object>> bills = wxBillAllService.listBill(wxBillAll, wxMerchant,false, false, false, false); | |||
| if (bills.size() > 0) { | |||
| Map<String, Object> bill = bills.get(0); | |||
| bill.put("userId", record.getbUserId()); | |||
| wxBillAllService.updateBill(bill); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL); | |||
| } | |||
| return; | |||
| } | |||
| WxBillAll wxBillAll = new WxBillAll(); | |||
| wxBillAll.setId(record.getBillId()); | |||
| wxBillAll.updateTenantInfo(record); | |||
| List<Map<String, Object>> bills = wxBillAllService.listBill(wxBillAll, null,false, false, false, false); | |||
| if (bills.size()==0) { | |||
| logger.error("pay success handle, bill " + record.getBillId() + " not found , payBillNo : " + record.getPayBillNo()); | |||
| throw new MallinkException(ErrorCode.BILL_ROUTINE_IS_NOT_FOUND); | |||
| } | |||
| Map<String, Object> bill; | |||
| bill = bills.get(0); | |||
| bill.put("userId", record.getbUserId()); | |||
| // 修改支付订单状态 | |||
| WxPayBill updateBill = new WxPayBill(); | |||
| updateBill.setId(record.getId()); | |||
| updateBill.setBillId(record.getBillId()); | |||
| updateBill.setUpdateTime(currentDate); | |||
| updateBill.setPayBillStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()); | |||
| updateBill.setTransactionId(transactionId); | |||
| try { | |||
| wxPayBillMapper.updateById(updateBill); | |||
| } catch (Exception e) { | |||
| logger.error("支付订单数据库更新失败: " + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "支付订单数据库更新失败: " + e.getMessage()); | |||
| } | |||
| //修改账单状态 | |||
| try { | |||
| wxBillAllService.updateBill(bill); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.BILL_UPDATE_FAILED); | |||
| } | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public void handlePayBillStatusUpdate(WxPayBill record) { | |||
| // 判断支付状态 | |||
| if (record.getPayBillStatus().equals(EnumPayStatus.PAY_STATUS_WAIT.getCode())) { | |||
| logger.error("pay handle, payBill " + record.getPayBillNo() + | |||
| "is complete, billId : " + record.getBillId()); | |||
| return; | |||
| } | |||
| WxBillAll wxBillAll = new WxBillAll(); | |||
| wxBillAll.setId(record.getBillId()); | |||
| wxBillAll.setBillTypeValue(record.getBillTypeValue()); | |||
| WxMerchantBUser buser = wxMerchantBUserService.getById(record.getbUserId()); | |||
| WxMerchant wxMerchant = wxMerchantService.getById(buser.getMerchantId()); | |||
| List<Map<String, Object>> bills = wxBillAllService.listBill(wxBillAll, wxMerchant,false, false, false, false); | |||
| if (bills.size()==0) { | |||
| logger.error("pay handle, bill " + record.getBillId() + " not found , payBillNo : " + record.getPayBillNo()); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| Map<String, Object> bill = bills.get(0); | |||
| if (record.getId() > 0) { | |||
| // 1. get appinfo | |||
| WxAppinfo appInfo = null; | |||
| WxAppinfo appinfoQ = new WxAppinfo(); | |||
| appinfoQ.setTenantId(bill.get("tenantId").toString()); | |||
| appinfoQ.setType(EnumAppType.B.getCode()); | |||
| List<WxAppinfo> appList = wxAppinfoService.getList(appinfoQ); | |||
| if (appList.size() > 0) { | |||
| appInfo = appList.get(0); | |||
| } | |||
| // 检查支付订单状态 | |||
| WxPayBill payBillQ = new WxPayBill(); | |||
| payBillQ.setId(record.getId()); | |||
| payBillQ.setTenantId(bill.get("tenantId").toString()); | |||
| payBillQ.setBillId(record.getBillId()); | |||
| WxPayBill updateBill; | |||
| try { | |||
| updateBill = wxPayBillMapper.selectOne(new QueryWrapper(payBillQ)); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND); | |||
| } | |||
| if (record.getPayBillStatus().equals(EnumPayStatus.PAY_STATUS_FAIL.getCode())) { | |||
| // 支付订单取消 | |||
| if (updateBill.getPayAmount() > 0) { | |||
| payBillQ = new WxPayBill(); | |||
| payBillQ.setTenantId(bill.get("tenantId").toString()); | |||
| payBillQ.setBillId(record.getBillId()); | |||
| List<WxPayBill> payBills = wxPayBillMapper.selectList(new QueryWrapper(payBillQ)); | |||
| for (WxPayBill payBill : payBills) { | |||
| if(payBill.getPayTimeEnd().before(new Date())){ | |||
| payBillClose(appInfo, payBill); | |||
| } | |||
| } | |||
| } | |||
| } else { | |||
| // 支付订单成功? | |||
| if (updateBill.getPayBillStatus().equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode())) { | |||
| if (!StringUtils.isBlank(updateBill.getTransactionId())) { | |||
| // 回调已设置成功 | |||
| wxBillAllService.updateBill(bill); | |||
| // 继续修改订单状态 | |||
| } else { | |||
| // 回调异常 | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "transactionId未获取"); | |||
| } | |||
| } else if (updateBill.getPayBillStatus().equals(EnumPayStatus.PAY_STATUS_WAIT.getCode())) { | |||
| // 回调未返回,主动检查支付订单状态 | |||
| try { | |||
| record.setPayBillNo(String.valueOf(record.getId())); | |||
| String response = wechatPayBillQuery(appInfo, record); | |||
| logger.info("pay bill query, " + record.toString() + ", response: " + response); | |||
| Map<String, String> returnMap = WxPayment.xmlToMap(response); | |||
| String result_code = returnMap.get("result_code"); | |||
| if ("SUCCESS".equals(result_code)) { | |||
| String trade_state = returnMap.get("trade_state"); | |||
| //SUCCESS—支付成功 | |||
| //REFUND—转入退款 | |||
| //NOTPAY—未支付 | |||
| //CLOSED—已关闭 | |||
| //REVOKED—已撤销(刷卡支付) | |||
| //USERPAYING--用户支付中 | |||
| //PAYERROR--支付失败(其他原因,如银行返回失败) | |||
| if ("SUCCESS".equals(trade_state)) { | |||
| // 查询支付订单 -- 已支付 | |||
| // 继续更改状态 | |||
| wxBillAllService.updateBill(bill); | |||
| } else { | |||
| // 支付订单未成功,返回异常 | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), "支付订单未成功"); | |||
| } | |||
| } | |||
| } catch (MallinkException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (RuntimeException e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| throw new MallinkException(ErrorCode.PAY_ORDER_ERROR.getCode(), e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -586,26 +586,6 @@ public class WxRefundOrderServiceImpl implements WxRefundOrderService { | |||
| } | |||
| } | |||
| /** | |||
| * 微信退款结果通知 | |||
| * | |||
| * @param paramMap 异步通知参数 | |||
| * @param payWay 支付方式 | |||
| * @return | |||
| */ | |||
| @Override | |||
| public String notify(Map<String, String> paramMap, EnumPayWay payWay,EnumPayVersion payVersion) { | |||
| RefundNotifyAdapterResult notifyResult = payServiceFactory.getRefundPayAdapterService(payWay.getCode(),payVersion.getCode()).notify(paramMap, payWay); | |||
| if (!notifyResult.isSuccess()) { | |||
| return notifyResult.getReturnJson(); | |||
| }else { | |||
| if (null != notifyResult.getRefundOrder()) { | |||
| handleRefundSuccess(notifyResult.getRefundOrder()); | |||
| } | |||
| return notifyResult.getReturnJson(); | |||
| } | |||
| } | |||
| @Override | |||
| public void callback(Map<String, String> paramMap, EnumPayWay payWay) { | |||
| @@ -1,12 +1,25 @@ | |||
| package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.CommonConstants; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.dto.sm.SaveThirdPartyApiDTO; | |||
| import com.iformall.domain.dto.sm.UpdateThirdPartyApiStatusDTO; | |||
| import com.iformall.domain.po.WxThirdPartyApi; | |||
| import com.iformall.domain.po.sm.ServiceInfo; | |||
| import com.iformall.exception.BizException; | |||
| import com.iformall.mapper.ServiceInfoMapper; | |||
| import com.iformall.mapper.WxThirdPartyApiMapper; | |||
| import com.iformall.service.WxThirdPartyApiService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import com.iformall.utils.sign.AppUtils; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -25,6 +38,8 @@ public class WxThirdPartyApiServiceImpl implements WxThirdPartyApiService { | |||
| @Autowired | |||
| WxThirdPartyApiMapper wxThirdPartyApiMapper; | |||
| @Autowired | |||
| private ServiceInfoMapper serviceInfoMapper; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| @@ -48,8 +63,65 @@ public class WxThirdPartyApiServiceImpl implements WxThirdPartyApiService { | |||
| WxThirdPartyApi apiQ = new WxThirdPartyApi(); | |||
| apiQ.setAppId(appId); | |||
| apiQ.setAppKey(appKey); | |||
| apiQ.setStatus(CommonConstants.STATUS_NORMAL); | |||
| apiConfig = wxThirdPartyApiMapper.selectOne(new QueryWrapper<>(apiQ)); | |||
| RedisCacheUtils.cache(redisTemplate, Constant.publicApi + appId, apiConfig,0l); | |||
| return apiConfig; | |||
| } | |||
| @Override | |||
| public PageInfo<WxThirdPartyApi> pageThirdPartyApi(WxThirdPartyApi thirdPartyApi, Integer pageNum, Integer pageSize) { | |||
| return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxThirdPartyApiMapper.listThirdPartyApi(thirdPartyApi)); | |||
| } | |||
| @Override | |||
| public void saveThirdPartyApi(SaveThirdPartyApiDTO dto) { | |||
| WxThirdPartyApi thirdPartyApi = buildThirdPartyApi(dto); | |||
| wxThirdPartyApiMapper.insert(thirdPartyApi); | |||
| } | |||
| @Override | |||
| public void updateThirdPartyApiStatus(UpdateThirdPartyApiStatusDTO dto) { | |||
| WxThirdPartyApi thirdPartyApi = wxThirdPartyApiMapper.selectOne(new LambdaQueryWrapper<WxThirdPartyApi>().eq(WxThirdPartyApi::getId, dto.getId())); | |||
| if (thirdPartyApi == null) { | |||
| throw new BizException(ErrorCode.SECRET_NOT_EXISTS); | |||
| } | |||
| ServiceInfo serviceInfo = serviceInfoMapper.selectOne(new LambdaQueryWrapper<ServiceInfo>().eq(ServiceInfo::getId, thirdPartyApi.getServiceId())); | |||
| if (serviceInfo == null || CommonConstants.STATUS_ABNORMAL.equals(serviceInfo.getStatus())) { | |||
| throw new BizException(ErrorCode.SERVICE_LOCKED); | |||
| } | |||
| wxThirdPartyApiMapper.update(null, new LambdaUpdateWrapper<WxThirdPartyApi>() | |||
| .set(WxThirdPartyApi::getStatus, dto.getStatus()) | |||
| .eq(WxThirdPartyApi::getId, dto.getId())); | |||
| } | |||
| @Override | |||
| public WxThirdPartyApi getThirdPartyApi(Long id) { | |||
| WxThirdPartyApi thirdPartyApi = new WxThirdPartyApi(); | |||
| thirdPartyApi.setId(id); | |||
| List<WxThirdPartyApi> vos = wxThirdPartyApiMapper.listThirdPartyApi(thirdPartyApi); | |||
| return !CollectionUtils.isEmpty(vos) ? vos.get(0) : null; | |||
| } | |||
| /** | |||
| * 构建秘钥实体 | |||
| * | |||
| * @param dto | |||
| * @return {@link WxThirdPartyApi} | |||
| */ | |||
| private WxThirdPartyApi buildThirdPartyApi(SaveThirdPartyApiDTO dto) { | |||
| WxThirdPartyApi thirdPartyApi = new WxThirdPartyApi(); | |||
| thirdPartyApi.setId(IdWorker.get().nextId()); | |||
| thirdPartyApi.setType(dto.getType()); | |||
| thirdPartyApi.setName(dto.getName()); | |||
| thirdPartyApi.setServiceId(dto.getServiceId()); | |||
| String appId = AppUtils.getAppId(); | |||
| String appKey = AppUtils.getAppKey(appId); | |||
| String signKey = AppUtils.getSignKey(appId, appKey); | |||
| thirdPartyApi.setAppId(appId); | |||
| thirdPartyApi.setAppKey(appKey); | |||
| thirdPartyApi.setSignKey(signKey); | |||
| thirdPartyApi.setStatus(CommonConstants.STATUS_NORMAL); | |||
| return thirdPartyApi; | |||
| } | |||
| } | |||