├── README.md ├── config ├── nacos_config │ ├── COMMON_GROUP │ │ ├── jwt.yaml │ │ ├── spring-boot-freemarker.yaml │ │ ├── spring-boot-http.yaml │ │ ├── spring-boot-mybatis-plus.yaml │ │ ├── spring-boot-redis.yaml │ │ ├── spring-boot-starter-druid.yaml │ │ └── sprint-boot-starter-rocketmq.yaml │ └── SHANJUPAY_GROUP │ │ ├── gateway-service.yaml │ │ ├── merchant-application.yaml │ │ ├── merchant-service.yaml │ │ ├── payment-agent-service.yaml │ │ ├── transaction-service.yaml │ │ ├── uaa-service.yaml │ │ └── user-service.yaml └── sql │ ├── shanjupay-init.sql │ └── shanjupay_saas.sql ├── pom.xml ├── sailing ├── README.md ├── pom.xml └── src │ └── main │ ├── docker │ ├── Dockerfile │ └── docker-compose.yml │ ├── java │ └── cn │ │ └── itcast │ │ └── sailing │ │ ├── SailingBootstrap.java │ │ ├── common │ │ ├── cache │ │ │ ├── Cache.java │ │ │ └── RedisCache.java │ │ ├── domain │ │ │ ├── BusinessException.java │ │ │ ├── CommonErrorCode.java │ │ │ ├── ErrorCode.java │ │ │ └── RestResponse.java │ │ └── intercept │ │ │ └── GlobalExceptionHandler.java │ │ ├── config │ │ ├── BusinessConfig.java │ │ ├── RedisConfig.java │ │ ├── SwaggerConfiguration.java │ │ └── WebMvcConfig.java │ │ ├── controller │ │ └── VerificationController.java │ │ ├── dto │ │ └── VerificationInfo.java │ │ ├── generator │ │ ├── NumberVerificationCodeGenerator.java │ │ ├── UUIDVerificationKeyGenerator.java │ │ ├── VerificationCodeGenerator.java │ │ └── VerificationKeyGenerator.java │ │ ├── handler │ │ ├── AbstractVerificationHandler.java │ │ └── SmsNumberVerificationHandler.java │ │ ├── service │ │ └── VerificationService.java │ │ ├── sms │ │ ├── SmsService.java │ │ └── qcloud │ │ │ ├── QCloudSmsService.java │ │ │ └── QCloudSmsSingleSender.java │ │ └── store │ │ ├── RedisVerificationStore.java │ │ └── VerificationStore.java │ └── resources │ ├── application.yml │ └── log4j2.xml ├── shanjupay-common ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── shanjupay │ └── common │ ├── cache │ └── Cache.java │ ├── domain │ ├── BusinessException.java │ ├── CommonErrorCode.java │ ├── ErrorCode.java │ ├── PageRequestParams.java │ ├── PageVO.java │ ├── RestErrorResponse.java │ └── RestResponse.java │ └── util │ ├── AmountUtil.java │ ├── DateUtil.java │ ├── EncryptUtil.java │ ├── IPUtil.java │ ├── IdWorkerUtils.java │ ├── JsonUtil.java │ ├── MD5Util.java │ ├── MapStringConvertUtil.java │ ├── ParseURLPairUtil.java │ ├── PaymentUtil.java │ ├── PhoneUtil.java │ ├── QRCodeUtil.java │ ├── QiniuUtils.java │ ├── RSAUtil.java │ ├── RandomStringUtil.java │ ├── RandomUuidUtil.java │ ├── RedisEnum.java │ ├── RedisUtil.java │ └── StringUtil.java ├── shanjupay-gateway ├── pom.xml └── shanjupay-gateway-service │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── shanjupay │ │ └── gateway │ │ ├── GatewayBootstrap.java │ │ ├── common │ │ └── util │ │ │ └── HttpUtil.java │ │ ├── config │ │ ├── ClientDefaultAccessTokenConverter.java │ │ ├── JWTConfig.java │ │ ├── ResouceServerConfig.java │ │ ├── RestAccessDeniedHandler.java │ │ ├── RestOAuth2AuthExceptionEntryPoint.java │ │ └── SecurityConfig.java │ │ └── filter │ │ └── AuthFilter.java │ └── resources │ ├── bootstrap.yml │ └── log4j2.xml ├── shanjupay-merchant-application ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shanjupay │ │ │ └── merchant │ │ │ ├── MerchantApplicationBootstrap.java │ │ │ ├── common │ │ │ ├── filter │ │ │ │ └── TokenAuthenticationFilter.java │ │ │ ├── intercept │ │ │ │ └── GlobalExceptionHandler.java │ │ │ └── util │ │ │ │ ├── ApplicationContextHelper.java │ │ │ │ ├── LoginUser.java │ │ │ │ └── SecurityUtil.java │ │ │ ├── config │ │ │ ├── RestTemplateConfig.java │ │ │ ├── SwaggerConfiguration.java │ │ │ └── WebMvcConfig.java │ │ │ ├── controller │ │ │ ├── AppController.java │ │ │ ├── MerchantController.java │ │ │ ├── PlatformParamController.java │ │ │ └── StoreController.java │ │ │ ├── convert │ │ │ ├── MerchantDetailConvert.java │ │ │ └── MerchantRegisterConvert.java │ │ │ ├── service │ │ │ ├── FileService.java │ │ │ ├── FileServiceImpl.java │ │ │ ├── SmsService.java │ │ │ └── SmsServiceImpl.java │ │ │ └── vo │ │ │ ├── MerchantDetailVO.java │ │ │ └── MerchantRegisterVO.java │ └── resources │ │ ├── bootstrap.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── com │ └── shanjupay │ └── merchant │ ├── RestTemplateTest.java │ └── TokenTemp.java ├── shanjupay-merchant ├── pom.xml ├── shanjupay-merchant-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── shanjupay │ │ └── merchant │ │ └── api │ │ ├── AppService.java │ │ ├── MerchantService.java │ │ └── dto │ │ ├── AppDTO.java │ │ ├── MerchantDTO.java │ │ ├── StaffDTO.java │ │ ├── StoreDTO.java │ │ └── StoreStaffDTO.java └── shanjupay-merchant-service │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── shanjupay │ │ └── merchant │ │ ├── MerchantBootstrap.java │ │ ├── config │ │ └── MybatisPlusConfig.java │ │ ├── convert │ │ ├── AppConvert.java │ │ ├── MerchantConvert.java │ │ ├── StaffConvert.java │ │ └── StoreConvert.java │ │ ├── entity │ │ ├── App.java │ │ ├── Merchant.java │ │ ├── Staff.java │ │ ├── Store.java │ │ └── StoreStaff.java │ │ ├── mapper │ │ ├── AppMapper.java │ │ ├── MerchantMapper.java │ │ ├── StaffMapper.java │ │ ├── StoreMapper.java │ │ └── StoreStaffMapper.java │ │ └── service │ │ ├── AppServiceImpl.java │ │ └── MerchantServiceImpl.java │ └── resources │ ├── bootstrap.yml │ └── log4j2.xml ├── shanjupay-payment-agent ├── pom.xml ├── shanjupay-payment-agent-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── shanjupay │ │ └── paymentagent │ │ └── api │ │ ├── PayChannelAgentService.java │ │ ├── conf │ │ ├── AliConfigParam.java │ │ └── WXConfigParam.java │ │ └── dto │ │ ├── AlipayBCScanBean.java │ │ ├── AlipayBean.java │ │ ├── CommonPayStatusDTO.java │ │ ├── GoodsDetail.java │ │ ├── OrderDTO.java │ │ ├── PaymentBillDTO.java │ │ ├── PaymentResponseDTO.java │ │ ├── TradeCreateResponse.java │ │ ├── TradeStatus.java │ │ ├── WeChatBean.java │ │ └── WeChatBeanScan.java └── shanjupay-payment-agent-service │ ├── logs │ ├── ${project.name}_error.log │ └── ${project.name}_info.log │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shanjupay │ │ │ └── paymentagent │ │ │ ├── PaymentAgentBootstrap.java │ │ │ ├── common │ │ │ └── AliCodeConstants.java │ │ │ ├── message │ │ │ ├── PayConsumer.java │ │ │ └── PayProducer.java │ │ │ └── service │ │ │ └── PayChannelAgentServiceImpl.java │ └── resources │ │ ├── bootstrap.yml │ │ └── log4j2.xml │ └── test │ └── java │ └── com │ └── shanjupay │ └── paymentagent │ └── service │ └── TestPayChannelAgentService.java ├── shanjupay-transaction ├── pom.xml ├── shanjupay-transaction-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── shanjupay │ │ └── transaction │ │ └── api │ │ ├── PayChannelService.java │ │ ├── TransactionService.java │ │ └── dto │ │ ├── OrderResultDTO.java │ │ ├── PayChannelDTO.java │ │ ├── PayChannelParamDTO.java │ │ ├── PayOrderDTO.java │ │ ├── PlatformChannelDTO.java │ │ └── QRCodeDTO.java └── shanjupay-transaction-service │ ├── logs │ ├── ${project.name}_error.log │ └── ${project.name}_info.log │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── shanjupay │ │ │ └── transaction │ │ │ ├── TransactionBootstrap.java │ │ │ ├── common │ │ │ └── util │ │ │ │ └── RedisCache.java │ │ │ ├── config │ │ │ ├── MybatisPlusConfig.java │ │ │ ├── RedisConfig.java │ │ │ ├── SwaggerConfiguration.java │ │ │ └── WebMvcConfig.java │ │ │ ├── controller │ │ │ ├── BrowserType.java │ │ │ ├── PayController.java │ │ │ └── PayTestController.java │ │ │ ├── convert │ │ │ ├── OrderResultConvert.java │ │ │ ├── PayChannelParamConvert.java │ │ │ ├── PayOrderConvert.java │ │ │ └── PlatformChannelConvert.java │ │ │ ├── entity │ │ │ ├── AppPlatformChannel.java │ │ │ ├── PayChannel.java │ │ │ ├── PayChannelParam.java │ │ │ ├── PayOrder.java │ │ │ ├── PaymentBill.java │ │ │ ├── PlatformChannel.java │ │ │ ├── PlatformPayChannel.java │ │ │ └── RefundOrder.java │ │ │ ├── mapper │ │ │ ├── AppPlatformChannelMapper.java │ │ │ ├── AppPlatformChannelMapper.xml │ │ │ ├── PayChannelMapper.java │ │ │ ├── PayChannelMapper.xml │ │ │ ├── PayChannelParamMapper.java │ │ │ ├── PayChannelParamMapper.xml │ │ │ ├── PayOrderMapper.java │ │ │ ├── PayOrderMapper.xml │ │ │ ├── PaymentBillMapper.java │ │ │ ├── PaymentBillMapper.xml │ │ │ ├── PlatformChannelMapper.java │ │ │ ├── PlatformChannelMapper.xml │ │ │ ├── PlatformPayChannelMapper.java │ │ │ ├── PlatformPayChannelMapper.xml │ │ │ ├── RefundOrderMapper.java │ │ │ └── RefundOrderMapper.xml │ │ │ ├── message │ │ │ └── TransactionPayConsumer.java │ │ │ ├── service │ │ │ ├── PayChannelServiceImpl.java │ │ │ └── TransactionServiceImpl.java │ │ │ └── vo │ │ │ └── OrderConfirmVO.java │ └── resources │ │ ├── bootstrap.yml │ │ ├── log4j2.xml │ │ └── templates │ │ ├── pay.html │ │ └── pay_error.html │ └── test │ └── java │ └── com │ └── shanjupay │ └── transaction │ └── TestPayChannelService.java ├── shanjupay-uaa ├── pom.xml ├── shanjupay-uaa-api │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── com │ │ └── shanjupay │ │ └── uua │ │ └── api │ │ ├── ClientDetailsService.java │ │ ├── OauthClientDetailsService.java │ │ └── dto │ │ └── MerchantLoginDTO.java └── shanjupay-uaa-service │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── com │ │ └── shanjupay │ │ └── uaa │ │ ├── UAABootstrap.java │ │ ├── common │ │ └── utils │ │ │ ├── ApplicationContextHelper.java │ │ │ ├── GuidGenerator.java │ │ │ ├── StringUtils.java │ │ │ └── WebUtils.java │ │ ├── config │ │ ├── AuthorizationServer.java │ │ ├── JWTConfig.java │ │ ├── SecurityConfig.java │ │ └── WebConfig.java │ │ ├── controller │ │ └── UUAController.java │ │ ├── domain │ │ ├── AuthPrincipal.java │ │ ├── OauthClientDetails.java │ │ └── UnifiedUserDetails.java │ │ ├── integration │ │ ├── ClientDefaultAccessTokenConverter.java │ │ ├── IntegrationUserDetailsAuthenticationHandler.java │ │ ├── IntegrationUserDetailsAuthenticationProvider.java │ │ ├── RestOAuth2Exception.java │ │ ├── RestOAuth2WebResponseExceptionTranslator.java │ │ ├── RestOAuthExceptionJacksonSerializer.java │ │ └── UnifiedUserAuthenticationConverter.java │ │ ├── repository │ │ ├── OauthClientDetailsRowMapper.java │ │ ├── OauthRepository.java │ │ └── OauthRepositoryJdbc.java │ │ └── service │ │ └── OauthClientDetailsServiceImpl.java │ └── resources │ ├── bootstrap.yml │ ├── log4j2.xml │ ├── static │ └── img │ │ ├── error.png │ │ ├── password.png │ │ └── username.png │ └── templates │ ├── login.html │ ├── oauth_approval.html │ └── oauth_error.html └── shanjupay-user ├── pom.xml ├── shanjupay-user-api ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── shanjupay │ └── user │ └── api │ ├── AuthorizationService.java │ ├── MenuService.java │ ├── ResourceService.java │ ├── TenantService.java │ └── dto │ ├── authorization │ ├── AuthorizationInfoDTO.java │ ├── PrivilegeDTO.java │ ├── PrivilegeGroupDTO.java │ ├── PrivilegeTreeDTO.java │ └── RoleDTO.java │ ├── menu │ ├── MenuDTO.java │ └── MenuQueryDTO.java │ ├── resource │ ├── ApplicationDTO.java │ ├── ApplicationQueryParams.java │ ├── ResourceAPPDTO.java │ └── ResourceDTO.java │ └── tenant │ ├── AbilityDTO.java │ ├── AccountDTO.java │ ├── AccountQueryDTO.java │ ├── AccountRoleDTO.java │ ├── AccountRoleQueryDTO.java │ ├── AuthenticationInfo.java │ ├── BundleDTO.java │ ├── ChangeAccountPwdDTO.java │ ├── CreateAccountRequestDTO.java │ ├── CreateTenantRequestDTO.java │ ├── LoginInfoDTO.java │ ├── LoginRequestDTO.java │ ├── TenRolePrivilegeDTO.java │ ├── TenantDTO.java │ └── TenantQueryDTO.java └── shanjupay-user-service ├── pom.xml └── src └── main ├── java └── com │ └── shanjupay │ └── user │ ├── UserBootstrap.java │ ├── config │ ├── MybatisPlusConfig.java │ └── SwaggerConfiguration.java │ ├── controller │ ├── AuthorizationController.java │ ├── ResourceController.java │ └── TenantController.java │ ├── convert │ ├── AccountConvert.java │ ├── AuthorizationPrivilegeConvert.java │ ├── AuthorizationRoleConvert.java │ ├── BundleConvert.java │ ├── ResourceApplicationConvert.java │ ├── ResourceMenuConvert.java │ ├── TenantConvert.java │ └── TenantRequestConvert.java │ ├── entity │ ├── Account.java │ ├── AccountRole.java │ ├── AuthorizationPrivilege.java │ ├── AuthorizationPrivilegeGroup.java │ ├── AuthorizationRole.java │ ├── AuthorizationRolePrivilege.java │ ├── Bundle.java │ ├── ResourceApplication.java │ ├── ResourceButton.java │ ├── ResourceMenu.java │ ├── Tenant.java │ ├── TenantAccount.java │ └── TenantType.java │ ├── mapper │ ├── AccountMapper.java │ ├── AccountMapper.xml │ ├── AccountRoleMapper.java │ ├── AuthorizationPrivilegeGroupMapper.java │ ├── AuthorizationPrivilegeMapper.java │ ├── AuthorizationRoleMapper.java │ ├── AuthorizationRolePrivilegeMapper.java │ ├── BundleMapper.java │ ├── ResourceApplicationMapper.java │ ├── ResourceButtonMapper.java │ ├── ResourceMenuMapper.java │ ├── TenantAccountMapper.java │ ├── TenantAccountMapper.xml │ ├── TenantMapper.java │ ├── TenantMapper.xml │ ├── TenantTypeMapper.java │ └── TenantTypeMapper.xml │ └── service │ ├── AuthorizationServiceImpl.java │ ├── MenuServiceImpl.java │ ├── ResourceServiceImpl.java │ └── TenantServiceImpl.java ├── resources ├── bootstrap.yml └── log4j2.xml └── test └── com └── shanjupay └── user ├── MapperTest.java └── TenRolePrivilegeDTO.java /README.md: -------------------------------------------------------------------------------- 1 | # 闪聚支付 2 | 3 | 闪聚支付采用当前流行的前后端分离架构开发,由用户层、UI层、微服务层、数据层等部分组成,为PC、H5等客 4 | 5 | 户端用户提供服务。 6 | 7 | ## 核心技术栈 8 | 9 | | 软件名称 | 描述 | 版本 | 10 | | --------------------- | ------------------ | --------------- | 11 | | Jdk | Java环境 | 1.8 | 12 | | Spring Boot | 开发框架 | 2.1.3 | 13 | | Spring Cloud Alibaba | 微服务框架 | 2.1.0 | 14 | | Spring Cloud Security | 用户认证 | | 15 | | Spring Cloud OAuth2.0 | 用户认证 | | 16 | | Nacos | 注册中心、配置中心 | | 17 | | Dubbo | RPC框架 | | 18 | | Redis | 缓存中间件 | 3.2.8 或 高版本 | 19 | | MySQL | 数据库 | 5.7.X | 20 | | RocketMQ | 消息中间件 | 4.5.0 | 21 | | MyBatis-Plus | 持久层框架 | 3.1.0 | 22 | | Swagger | 接口规范 | | 23 | 24 | ## 项目架构 25 | 26 | ``` 27 | shanjupay 28 | ├── config -- nacos配置文件,初始化sql语句 29 | ├── sailing -- 发送验证码服务 30 | ├── shanjupay-common -- 核心依赖包 31 | ├── shanjupay-gateway -- Saas平台,网关层 32 | ├── shanjupay-merchant-application -- 应用层,提供http接口 33 | ├── shanjupay-merchant -- 商户服务 34 | ├── shanjupay-payment-agent -- 支付服务 35 | ├── shanjupay-trasaction -- 交易服务 36 | ├── shanjupay-uaa -- Saas平台,用户认证授权 37 | └── shanjupay-user -- Saas平台,用户认证授权 38 | ``` 39 | ## 主要功能 40 | 1. 使用Nginx+Zuul实现网关层,完成负载均衡、路由转发、请求过滤,使用Nacos作为注册中心 41 | 和配置中心,使用Dubbo完成微服务间的rpc远程调用。 42 | 2. 使用SpringSecurity+JWT+OAuth2完成租户管理、用户管理、角色及权限管理和统一认证, 43 | 实现简易的SaaS平台,作为系统的服务提供平台。 44 | 3. 整合阿里云短信服务以及Redis缓存搭建短信验证系统,为闪聚支付平台提供http服务,使用 45 | 七牛云服务器存放商户资质认证照片。 46 | 4. 闪聚支付平台对接支付宝和微信的开放API提供C扫B和B扫C的支付服务,使用消息队列 47 | RocketMQ完成支付渠道代理服务与交易服务之间的通信。 48 | -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/jwt.yaml: -------------------------------------------------------------------------------- 1 | siging-key: shanju123 -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/spring-boot-freemarker.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | freemarker: 3 | charset: UTF-8 4 | request-context-attribute: rc 5 | context-type: text/html 6 | suffix: .html 7 | enabled: true 8 | resources: 9 | add-mappings: false 10 | mvc: 11 | throw-exception-if-no-handler-found: true -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/spring-boot-http.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | http: 3 | encoding: 4 | charset: UTF-8 5 | force: true 6 | enabled: true 7 | messages: 8 | encoding: UTF-8 9 | server: 10 | tomcat: 11 | remote_ip_header: x-forwarded-for 12 | protocol_header: x-forwarded-proto 13 | servlet: 14 | context-path: / 15 | use-forward-headers: true 16 | management: 17 | endpoints: 18 | web: 19 | exposure: 20 | include: refresh,health,info,env -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/spring-boot-mybatis-plus.yaml: -------------------------------------------------------------------------------- 1 | mybatis-plus: 2 | configuration: 3 | cache-enabled: false 4 | map-underscore-to-camel-case: true 5 | global-config: 6 | db-config: 7 | column-like: true 8 | id-type: auto 9 | field-strategy: ignored 10 | table-underline: true 11 | type-aliases-package: com.shanjupay.user.entity 12 | mapper-locations: classpath:com/shanjupay/*/mapper/*.xml 13 | -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/spring-boot-redis.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | redis: 3 | database: 0 4 | host: 192.168.249.150 5 | port: 6379 6 | timeout: 1000ms 7 | lettuce: 8 | pool: 9 | max-idle: 8 10 | min-idle: 0 11 | max-active: 8 12 | max-wait: 1000ms 13 | shutdown-timeout: 1000ms -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/spring-boot-starter-druid.yaml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | type: com.alibaba.druid.pool.DruidDataSource 4 | driver-class-name: com.mysql.cj.jdbc.Driver 5 | url: jdbc:mysql://localhost:3307/database?useUnicode=true 6 | username: username 7 | password: password 8 | druid: 9 | initial-size: 5 10 | min-idle: 5 11 | max-active: 20 12 | max-wait: 60000 13 | time-between-eviction-runs-millis: 60000 14 | min-evictable-idle-time-millis: 300000 15 | validation-query: SELECT 1 FROM DUAL 16 | test-while-idle: true 17 | test-on-borrow: true 18 | test-on-return: false 19 | pool-prepared-statements: true 20 | max-pool-prepared-statement-per-connection-size: 20 21 | filter: 22 | stat: 23 | slow-sql-millis: 1 24 | log-slow-sql: true 25 | filters: config,stat,wall,log4j2 26 | web-stat-filter: 27 | enabled: true 28 | url-pattern: /* 29 | exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" 30 | session-stat-enable: false 31 | session-stat-max-count: 1000 32 | principal-cookie-name: admin 33 | principal-session-name: admin 34 | profile-enable: true 35 | stat-view-servlet: 36 | enabled: true 37 | url-pattern: /druid/* 38 | allow: 127.0.0.1,192.168.2.149 39 | deny: 192.168.1.73 40 | reset-enable: false 41 | login-username: admin 42 | login-password: admin 43 | aop-patterns: com.shanjupay.*.service.* -------------------------------------------------------------------------------- /config/nacos_config/COMMON_GROUP/sprint-boot-starter-rocketmq.yaml: -------------------------------------------------------------------------------- 1 | rocketmq: 2 | nameServer: 127.0.0.1:9876 3 | producer: 4 | group: PID_PAY_PRODUCER -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/gateway-service.yaml: -------------------------------------------------------------------------------- 1 | #路由规则 2 | zuul: 3 | retryable: true 4 | add-host-header: true 5 | ignoredServices: "*" 6 | sensitiveHeaders: "*" 7 | routes: 8 | operation-application: 9 | path: /operation/** 10 | stripPrefix: false 11 | merchant-application: 12 | path: /merchant/** 13 | stripPrefix: false 14 | uaa-service: 15 | path: /uaa/** 16 | stripPrefix: false 17 | transaction-service: 18 | path: /transaction/** 19 | stripPrefix: false 20 | 21 | feign: 22 | hystrix: 23 | enabled: true 24 | compression: 25 | request: 26 | enabled: true 27 | mime-types: ["text/xml","application/xml","application/json"] 28 | min-request-size: 2048 29 | response: 30 | enabled: true 31 | 32 | hystrix: 33 | command: 34 | default: 35 | execution: 36 | isolation: 37 | thread: 38 | timeoutInMilliseconds: 93000 # 设置熔断超时时间 default 1000 39 | timeout: 40 | enabled: true # 打开超时熔断功能 default true 41 | 42 | ribbon: 43 | nacos: 44 | enabled: true # 不知道是否生效 45 | ConnectTimeout: 3000 # 设置连接超时时间 default 2000 46 | ReadTimeout: 20000 # 设置读取超时时间 default 5000 47 | OkToRetryOnAllOperations: false # 对所有操作请求都进行重试 default false 48 | MaxAutoRetriesNextServer: 1 # 切换实例的重试次数 default 1 49 | MaxAutoRetries: 1 # 对当前实例的重试次数 default 0 -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/merchant-application.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /merchant 4 | swagger: 5 | enable: true 6 | sms: 7 | url: "http://localhost:56085/sailing" 8 | effectiveTime: 600 9 | oss: 10 | qiniu: 11 | url: "http://quulrz3vx.hd-bkt.clouddn.com/" 12 | accessKey: "GFoUrDSZejTDpEbjZhKv5DISfukm0leiBuzo_1k-" 13 | secretKey: "j9vDdcHOH8e2mVKNbEmYsqTKYHUlSv9jnzFSPnAv" 14 | bucket: "shanjupay-dys" 15 | shanjupay: 16 | c2b: 17 | subject: "%s商品" 18 | body: "向%s付款" -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/merchant-service.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /merchant-service 4 | spring: 5 | datasource: 6 | url: jdbc:mysql://localhost:3307/shanjupay_merchant_service?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false 7 | username: root 8 | password: root 9 | myabtis-plus: 10 | typeAliasesPackage: com.shanjupay.merchant.entity 11 | mapper-locations: classpath:com/shanjupay/*/mapper/*.xml -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/payment-agent-service.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /payment-receiver -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/transaction-service.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /transaction 4 | spring: 5 | datasource: 6 | druid: 7 | url: jdbc:mysql://127.0.0.1:3307/shanjupay_transaction?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false 8 | username: root 9 | password: root 10 | mybatis-plus: 11 | typeAliasesPackage: com.shanjupay.transaction.entity 12 | mapper-locations: classpath:com/shanjupay/*/mapper/*.xml 13 | shanjupay: 14 | payurl: "http://192.168.2.149:56010/transaction/pay-entry" -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/uaa-service.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /uaa 4 | spring: 5 | datasource: 6 | druid: 7 | url: jdbc:mysql://127.0.0.1:3307/shanjupay_uaa?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false 8 | username: root 9 | password: root -------------------------------------------------------------------------------- /config/nacos_config/SHANJUPAY_GROUP/user-service.yaml: -------------------------------------------------------------------------------- 1 | server: 2 | servlet: 3 | context-path: /user 4 | spring: 5 | datasource: 6 | druid: 7 | url: jdbc:mysql://127.0.0.1:3307/shanjupay_user?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false 8 | username: root 9 | password: root 10 | mybatis-plus: 11 | typeAliasesPackage: com.shanjupay.user.entity 12 | mapper-locations: classpath:com/shanjupay/*/mapper/xml/*.xml 13 | sms: 14 | url: "http://localhost:56085/sailing" 15 | effectiveTime: 6000 -------------------------------------------------------------------------------- /sailing/src/main/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8-jre-alpine 2 | 3 | ENV VERSION 1.0-SNAPSHOT 4 | 5 | RUN echo "http://mirrors.aliyun.com/alpine/v3.8/main" > /etc/apk/repositories \ 6 | && echo "http://mirrors.aliyun.com/alpine/v3.8/community" >> /etc/apk/repositories \ 7 | && apk update upgrade \ 8 | && apk add --no-cache procps curl bash tzdata \ 9 | && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ 10 | && echo "Asia/Shanghai" > /etc/timezone 11 | 12 | ADD sailing-${VERSION}.jar sailing.jar 13 | RUN bash -c 'touch /sailing.jar' 14 | 15 | EXPOSE 56085 16 | 17 | ENV JAVA_OPTS="" 18 | ENTRYPOINT ["bash", "-c", "java $JAVA_OPTS -jar /sailing.jar"] 19 | -------------------------------------------------------------------------------- /sailing/src/main/docker/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | redis: 5 | image: redis:5.0.5 6 | container_name: redis 7 | restart: always 8 | network_mode: "host" 9 | ports: 10 | - "6379:6379" 11 | volumes: 12 | - ./data:/data 13 | command: redis-server 14 | tty: true 15 | 16 | sailing: 17 | container_name: sailing 18 | build: . 19 | image: sailing:1.0-SNAPSHOT 20 | network_mode: "host" 21 | ports: 22 | - "56085:56085" 23 | restart: always 24 | depends_on: 25 | - redis 26 | volumes: 27 | - "./logs:/logs" 28 | environment: 29 | JAVA_OPTS: "-Xms256m -Xmx256m -Xmn128m" -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/SailingBootstrap.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | 7 | @SpringBootApplication 8 | public class SailingBootstrap { 9 | 10 | public static void main(String[] args) { 11 | SpringApplication.run(SailingBootstrap.class, args); 12 | } 13 | 14 | } -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/common/domain/BusinessException.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.common.domain; 2 | 3 | 4 | /** 5 | * 业务异常 6 | */ 7 | public class BusinessException extends RuntimeException { 8 | 9 | private static final long serialVersionUID = 5565760508056698922L; 10 | 11 | private ErrorCode errorCode; 12 | 13 | public BusinessException(ErrorCode errorCode) { 14 | super(); 15 | this.errorCode = errorCode; 16 | } 17 | 18 | public BusinessException() { 19 | super(); 20 | } 21 | 22 | public BusinessException(String arg0, Throwable arg1, boolean arg2, boolean arg3) { 23 | super(arg0, arg1, arg2, arg3); 24 | } 25 | 26 | public BusinessException(ErrorCode errorCode, String arg0, Throwable arg1, boolean arg2, boolean arg3) { 27 | super(arg0, arg1, arg2, arg3); 28 | this.errorCode = errorCode; 29 | } 30 | 31 | public BusinessException(String arg0, Throwable arg1) { 32 | super(arg0, arg1); 33 | } 34 | 35 | public BusinessException(ErrorCode errorCode, String arg0, Throwable arg1) { 36 | super(arg0, arg1); 37 | this.errorCode = errorCode; 38 | } 39 | 40 | public BusinessException(String arg0) { 41 | super(arg0); 42 | } 43 | 44 | public BusinessException(ErrorCode errorCode, String arg0) { 45 | super(arg0); 46 | this.errorCode = errorCode; 47 | } 48 | 49 | public BusinessException(Throwable arg0) { 50 | super(arg0); 51 | } 52 | 53 | public BusinessException(ErrorCode errorCode, Throwable arg0) { 54 | super(arg0); 55 | this.errorCode = errorCode; 56 | } 57 | 58 | public ErrorCode getErrorCode() { 59 | return errorCode; 60 | } 61 | 62 | public void setErrorCode(ErrorCode errorCode) { 63 | this.errorCode = errorCode; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/common/domain/CommonErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.common.domain; 2 | 3 | 4 | public enum CommonErrorCode implements ErrorCode { 5 | 6 | SUCCESS(0, "成功"), 7 | 8 | CUSTOM(999998, "自定义异常"), 9 | 10 | UNKNOWN(999999, "未知错误"); 11 | 12 | 13 | private int code; 14 | private String desc; 15 | 16 | public int getCode() { 17 | return code; 18 | } 19 | 20 | public String getDesc() { 21 | return desc; 22 | } 23 | 24 | CommonErrorCode(int code, String desc) { 25 | this.code = code; 26 | this.desc = desc; 27 | } 28 | 29 | public static CommonErrorCode setErrorCode(int code) { 30 | for (CommonErrorCode errorCode : CommonErrorCode.values()) { 31 | if (errorCode.getCode() == code) { 32 | return errorCode; 33 | } 34 | } 35 | return null; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/common/domain/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.common.domain; 2 | 3 | public interface ErrorCode { 4 | 5 | int getCode(); 6 | 7 | String getDesc(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/config/BusinessConfig.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.config; 2 | 3 | 4 | import cn.itcast.sailing.handler.AbstractVerificationHandler; 5 | import cn.itcast.sailing.handler.SmsNumberVerificationHandler; 6 | import cn.itcast.sailing.sms.qcloud.QCloudSmsService; 7 | import cn.itcast.sailing.store.VerificationStore; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | @Configuration 18 | public class BusinessConfig { 19 | 20 | @Autowired 21 | private VerificationStore verificationStore; 22 | 23 | @Autowired 24 | private QCloudSmsService qCloudSmsService; 25 | 26 | @Bean 27 | public SmsNumberVerificationHandler smsNumberVerificationHandler() { 28 | SmsNumberVerificationHandler smsNumberVerificationHandler = new SmsNumberVerificationHandler("sms", 6); 29 | smsNumberVerificationHandler.setVerificationStore(verificationStore); 30 | smsNumberVerificationHandler.setSmsService(qCloudSmsService); 31 | return smsNumberVerificationHandler; 32 | } 33 | 34 | @Bean 35 | public Map verificationHandlerMap() { 36 | List verificationHandlerList = new ArrayList<>(); 37 | verificationHandlerList.add(smsNumberVerificationHandler()); 38 | 39 | Map verificationHandlerMap = new HashMap<>(); 40 | for (AbstractVerificationHandler handler : verificationHandlerList) { 41 | verificationHandlerMap.put(handler.getName(), handler); 42 | } 43 | return verificationHandlerMap; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.config; 2 | 3 | 4 | import cn.itcast.sailing.common.cache.Cache; 5 | import cn.itcast.sailing.common.cache.RedisCache; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.data.redis.core.StringRedisTemplate; 9 | 10 | 11 | @Configuration 12 | public class RedisConfig { 13 | 14 | @Bean 15 | public Cache cache(StringRedisTemplate redisTemplate){ 16 | return new RedisCache(redisTemplate); 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.config; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | @Configuration 16 | @ConditionalOnProperty(prefix = "swagger",value = {"enable"},havingValue = "true") 17 | @EnableSwagger2 18 | public class SwaggerConfiguration { 19 | 20 | @Bean 21 | public Docket buildDocket() { 22 | return new Docket(DocumentationType.SWAGGER_2) 23 | .apiInfo(buildApiInfo()) 24 | .select() 25 | // 要扫描的API(Controller)基础包 26 | .apis(RequestHandlerSelectors.basePackage("cn.itcast.sailing.controller")) 27 | .paths(PathSelectors.any()) 28 | .build(); 29 | } 30 | 31 | /** 32 | * @param 33 | * @return springfox.documentation.service.ApiInfo 34 | * @Title: 构建API基本信息 35 | * @methodName: buildApiInfo 36 | */ 37 | private ApiInfo buildApiInfo() { 38 | Contact contact = new Contact("徐帆","",""); 39 | return new ApiInfoBuilder() 40 | .title("验证码服务API文档") 41 | .description("包含验证码、短信api") 42 | .contact(contact) 43 | .version("1.0.0").build(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.config; 2 | 3 | 4 | import org.springframework.stereotype.Component; 5 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 6 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 7 | 8 | @Component 9 | public class WebMvcConfig implements WebMvcConfigurer { 10 | /** 11 | * 添加静态资源文件,外部可以直接访问地址 12 | * 13 | * @param registry 14 | */ 15 | @Override 16 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 17 | registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); 18 | 19 | registry.addResourceHandler("swagger-ui.html") 20 | .addResourceLocations("classpath:/META-INF/resources/"); 21 | 22 | registry.addResourceHandler("/webjars/**") 23 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 24 | } 25 | } -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/dto/VerificationInfo.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.dto; 2 | 3 | 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | 7 | /** 8 | * 验证信息,客户端保存key,展示content 9 | */ 10 | @Data 11 | @AllArgsConstructor 12 | public class VerificationInfo { 13 | 14 | /** 15 | * 16 | */ 17 | private String key; 18 | 19 | /** 20 | * 混淆后的内容 21 | * 举例: 22 | * 1.图片验证码为:图片base64编码 23 | * 2.短信验证码为:null 24 | * 3.邮件验证码为: null 25 | * 4.邮件链接点击验证为:null 26 | * ... 27 | */ 28 | private String content; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/generator/NumberVerificationCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.generator; 2 | 3 | import java.util.Random; 4 | 5 | public class NumberVerificationCodeGenerator implements VerificationCodeGenerator { 6 | 7 | 8 | public NumberVerificationCodeGenerator(int len){ 9 | this.len = len; 10 | } 11 | 12 | private int len; 13 | 14 | @Override 15 | public String generate() { 16 | return getNumRandom(len); 17 | } 18 | 19 | private String getNumRandom(int length) { 20 | String val = ""; 21 | Random random = new Random(); 22 | for(int i = 0; i < length; i++) { 23 | val += String.valueOf(random.nextInt(10)); 24 | } 25 | return val; 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/generator/UUIDVerificationKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.generator; 2 | 3 | import java.util.UUID; 4 | 5 | public class UUIDVerificationKeyGenerator implements VerificationKeyGenerator { 6 | @Override 7 | public String generate(String prefix) { 8 | String uuid = UUID.randomUUID().toString(); 9 | return prefix + uuid.replaceAll("-", ""); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/generator/VerificationCodeGenerator.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.generator; 2 | 3 | /** 4 | * 认证码生成器 5 | */ 6 | public interface VerificationCodeGenerator { 7 | 8 | /** 9 | * 认证码生成 10 | * @return 11 | */ 12 | String generate(); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/generator/VerificationKeyGenerator.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.generator; 2 | 3 | /** 4 | * 验证key生成器 5 | */ 6 | public interface VerificationKeyGenerator { 7 | String generate(String prefix); 8 | } 9 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/sms/SmsService.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.sms; 2 | 3 | /** 4 | *

5 | * 短信服务 6 | *

7 | * 8 | * @author zhupeiyuan 9 | * @since 2019-07-12 10 | */ 11 | public interface SmsService { 12 | 13 | /** 14 | * 发送短信 15 | * @param mobile 16 | * @param content 17 | * @return 18 | */ 19 | default void send(String mobile, String content) { 20 | } 21 | 22 | /** 23 | * 发送短信验证码 24 | * @param mobile 25 | * @param code 26 | * @param effectiveTime 27 | * @return 28 | */ 29 | void send(String mobile, String code, int effectiveTime); 30 | 31 | /** 32 | * 在控制台输出验证码,模拟发送短信 33 | * @param mobile 34 | * @param code 35 | * @param effectiveTime 36 | * @return 37 | */ 38 | void sendOnConsole(String mobile, String code, int effectiveTime); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/store/RedisVerificationStore.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.store; 2 | 3 | import cn.itcast.sailing.common.cache.Cache; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public class RedisVerificationStore implements VerificationStore { 9 | 10 | @Autowired 11 | private Cache cache; 12 | 13 | @Override 14 | public void set(String key, String value, Integer expire) { 15 | cache.set(key,value,expire); 16 | } 17 | 18 | @Override 19 | public String get(String key) { 20 | return cache.get(key); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sailing/src/main/java/cn/itcast/sailing/store/VerificationStore.java: -------------------------------------------------------------------------------- 1 | package cn.itcast.sailing.store; 2 | 3 | /** 4 | * 验证信息存储 kv 5 | */ 6 | public interface VerificationStore{ 7 | 8 | 9 | void set(String key, String value, Integer expire); 10 | 11 | 12 | String get(String key); 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /sailing/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 56085 3 | servlet: 4 | context-path: /sailing 5 | 6 | spring: 7 | application: 8 | name: sailing 9 | 10 | main: 11 | allow-bean-definition-overriding: true 12 | 13 | 14 | 15 | jackson: 16 | date-format: yyyy-MM-dd HH:mm:ss 17 | time-zone: GMT+8 18 | 19 | redis: 20 | host: 192.168.249.150 21 | port: 6379 22 | shutdown-timeout: 100 23 | lettuce: 24 | pool: 25 | max-idle: 8 26 | min-idle: 0 27 | max-active: 8 28 | max-wait: 10000 29 | timeout: 10000 30 | # password: 123456 31 | 32 | sms: 33 | qcloud: 34 | appId: 0 35 | appKey: appKey 36 | templateId: 0 37 | sign: 签名 38 | 39 | swagger: 40 | enable: true 41 | 42 | logging: 43 | config: classpath:log4j2.xml 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/domain/BusinessException.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | package com.shanjupay.common.domain; 4 | 5 | 6 | 7 | public class BusinessException extends RuntimeException { 8 | 9 | 10 | private static final long serialVersionUID = 5565760508056698922L; 11 | 12 | private ErrorCode errorCode; 13 | 14 | public BusinessException(ErrorCode errorCode) { 15 | super(); 16 | this.errorCode = errorCode; 17 | } 18 | 19 | public BusinessException() { 20 | super(); 21 | } 22 | 23 | public BusinessException(String arg0, Throwable arg1, boolean arg2, boolean arg3) { 24 | super(arg0, arg1, arg2, arg3); 25 | } 26 | 27 | public BusinessException(ErrorCode errorCode, String arg0, Throwable arg1, boolean arg2, boolean arg3) { 28 | super(arg0, arg1, arg2, arg3); 29 | this.errorCode = errorCode; 30 | } 31 | 32 | public BusinessException(String arg0, Throwable arg1) { 33 | super(arg0, arg1); 34 | } 35 | 36 | public BusinessException(ErrorCode errorCode, String arg0, Throwable arg1) { 37 | super(arg0, arg1); 38 | this.errorCode = errorCode; 39 | } 40 | 41 | public BusinessException(String arg0) { 42 | super(arg0); 43 | } 44 | 45 | public BusinessException(ErrorCode errorCode, String arg0) { 46 | super(arg0); 47 | this.errorCode = errorCode; 48 | } 49 | 50 | public BusinessException(Throwable arg0) { 51 | super(arg0); 52 | } 53 | 54 | public BusinessException(ErrorCode errorCode, Throwable arg0) { 55 | super(arg0); 56 | this.errorCode = errorCode; 57 | } 58 | 59 | public ErrorCode getErrorCode() { 60 | return errorCode; 61 | } 62 | 63 | public void setErrorCode(ErrorCode errorCode) { 64 | this.errorCode = errorCode; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/domain/ErrorCode.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.domain; 2 | 3 | public interface ErrorCode { 4 | 5 | int getCode(); 6 | 7 | String getDesc(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/domain/PageRequestParams.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | package com.shanjupay.common.domain; 5 | 6 | 7 | public class PageRequestParams { 8 | 9 | private long startRow; 10 | 11 | private long limit; 12 | 13 | private PageRequestParams(Long startRow, Long limit){ 14 | this.startRow = startRow; 15 | this.limit = limit; 16 | } 17 | 18 | public static PageRequestParams of(Integer pageNo, Integer pageSize){ 19 | Long startRow = Long.valueOf((pageNo - 1) * pageSize); 20 | Long limit = Long.valueOf((pageSize)); 21 | return new PageRequestParams(startRow , limit); 22 | } 23 | 24 | public long getStartRow() { 25 | return startRow; 26 | } 27 | 28 | public void setStartRow(long startRow) { 29 | this.startRow = startRow; 30 | } 31 | 32 | public long getLimit() { 33 | return limit; 34 | } 35 | 36 | public void setLimit(long limit) { 37 | this.limit = limit; 38 | } 39 | 40 | 41 | 42 | } 43 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/domain/RestErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.domain; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import lombok.Data; 5 | 6 | /** 7 | * @author Administrator 8 | * @version 1.0 9 | **/ 10 | @ApiModel(value = "RestErrorResponse", description = "错误响应参数包装") 11 | @Data 12 | public class RestErrorResponse { 13 | 14 | private String errCode; 15 | 16 | private String errMessage; 17 | 18 | public RestErrorResponse(String errCode,String errMessage){ 19 | this.errCode = errCode; 20 | this.errMessage= errMessage; 21 | } 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/util/MD5Util.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.util; 2 | 3 | import java.security.MessageDigest; 4 | import java.security.NoSuchAlgorithmException; 5 | 6 | 7 | public class MD5Util { 8 | /** 9 | * 获取字符串的MD5摘要计算结果 10 | * @param plainText 11 | * @return 12 | */ 13 | public static String getMd5(String plainText) { 14 | try { 15 | MessageDigest md = MessageDigest.getInstance("MD5"); 16 | md.update(plainText.getBytes()); 17 | byte b[] = md.digest(); 18 | 19 | int i; 20 | 21 | StringBuffer buf = new StringBuffer(""); 22 | for (int offset = 0; offset < b.length; offset++) { 23 | i = b[offset]; 24 | if (i < 0) 25 | i += 256; 26 | if (i < 16) 27 | buf.append("0"); 28 | buf.append(Integer.toHexString(i)); 29 | } 30 | //32位加密 31 | return buf.toString(); 32 | // 16位的加密 33 | //return buf.toString().substring(8, 24); 34 | } catch (NoSuchAlgorithmException e) { 35 | e.printStackTrace(); 36 | return null; 37 | } 38 | 39 | } 40 | 41 | //public static void main(String[] args) { 42 | // String nihao = getMd5("123456string"); 43 | // System.out.println(nihao); 44 | //} 45 | } 46 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/util/ParseURLPairUtil.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.util; 2 | 3 | import java.lang.reflect.Field; 4 | import java.util.Iterator; 5 | import java.util.Map; 6 | import java.util.Set; 7 | import java.util.TreeMap; 8 | 9 | public class ParseURLPairUtil { 10 | 11 | public static String parseURLPair(Object o) throws Exception{ 12 | Class c = o.getClass(); 13 | Field[] fields = c.getDeclaredFields(); 14 | Map map = new TreeMap(); 15 | for (Field field : fields) { 16 | field.setAccessible(true); 17 | String name = field.getName(); 18 | Object value = field.get(o); 19 | if(value != null) 20 | map.put(name, value); 21 | } 22 | Set> set = map.entrySet(); 23 | Iterator> it = set.iterator(); 24 | StringBuffer sb = new StringBuffer(); 25 | while (it.hasNext()) { 26 | Map.Entry e = it.next(); 27 | sb.append(e.getKey()).append("=").append(e.getValue()).append("&"); 28 | } 29 | return sb.deleteCharAt(sb.length()-1).toString(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/util/PaymentUtil.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.util; 2 | 3 | import org.apache.commons.lang.RandomStringUtils; 4 | import org.apache.commons.lang.StringUtils; 5 | 6 | import java.time.LocalDateTime; 7 | import java.time.format.DateTimeFormatter; 8 | import java.util.regex.Pattern; 9 | 10 | public class PaymentUtil { 11 | 12 | private static final Pattern pattern = Pattern.compile("SJPAY(,\\S+){4}"); 13 | private static final String SHANJUPAY_PREFIX = "SJ"; 14 | 15 | public static boolean checkPayOrderAttach(String attach) { 16 | if (StringUtils.isBlank(attach)) { 17 | return false; 18 | } 19 | return pattern.matcher(attach).matches(); 20 | } 21 | 22 | public static String genUniquePayOrderNo() { 23 | return SHANJUPAY_PREFIX + WorkId(); 24 | } 25 | 26 | public static String WorkId() { 27 | long id = IdWorkerUtils.getInstance().nextId(); 28 | return String.valueOf(id); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/util/PhoneUtil.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.util; 2 | 3 | import java.util.regex.Matcher; 4 | import java.util.regex.Pattern; 5 | 6 | public class PhoneUtil { 7 | /** 8 | * 校验用户手机号是否合法 9 | * @param phone 10 | * @return 11 | */ 12 | public static Boolean isMatches(String phone){ 13 | String regex = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(17[013678])|(18[0,5-9]))\\d{8}$"; 14 | Pattern p = Pattern.compile(regex); 15 | Matcher m = p.matcher(phone); 16 | return m.matches(); 17 | } 18 | 19 | //public static void main(String[] args) { 20 | // System.out.println(isMatches("13512341233")); 21 | //} 22 | } 23 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/util/RandomStringUtil.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.util; 2 | 3 | 4 | import org.apache.commons.lang.RandomStringUtils; 5 | 6 | import java.util.Random; 7 | 8 | /** 9 | * 随机字符串工具 10 | * 11 | * @author scq 12 | * 13 | */ 14 | public class RandomStringUtil { 15 | /** 16 | * 获取指定长度随机字符串 17 | * 18 | * @param length 19 | * @return 20 | */ 21 | public static String getRandomString(int length) { 22 | Random random = new Random(); 23 | StringBuffer sb = new StringBuffer(); 24 | for (int i = 0; i < length; i++) { 25 | int number = random.nextInt(3); 26 | long result = 0; 27 | switch (number) { 28 | case 0: 29 | result = Math.round(Math.random() * 25 + 65); 30 | sb.append(String.valueOf((char) result)); 31 | break; 32 | case 1: 33 | result = Math.round(Math.random() * 25 + 97); 34 | sb.append(String.valueOf((char) result)); 35 | break; 36 | case 2: 37 | sb.append(String.valueOf(new Random().nextInt(10))); 38 | break; 39 | } 40 | } 41 | return sb.toString(); 42 | } 43 | 44 | /** 45 | * 测试验证 46 | * 47 | * @param args 48 | */ 49 | //public static void main(String[] args) { 50 | // System.out.println(RandomStringUtil.getRandomString(5)); 51 | // String str2 = RandomStringUtils.random(12,"123456789"); 52 | // System.out.println(str2); 53 | //} 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shanjupay-common/src/main/java/com/shanjupay/common/util/RandomUuidUtil.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.common.util; 2 | 3 | import java.util.UUID; 4 | 5 | /** 6 | * 随机UUID工具 7 | * 效果:b5e8863950d649ffa5a372dd0e951416 8 | * @author scq 9 | * 10 | */ 11 | public class RandomUuidUtil { 12 | 13 | public static String getUUID(){ 14 | UUID uuid=UUID.randomUUID(); 15 | String str = uuid.toString(); 16 | String uuidStr=str.replace("-", ""); 17 | return uuidStr; 18 | } 19 | 20 | //public static void main(String[] args) { 21 | // System.out.println(getUUID()); 22 | //} 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-gateway/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-gateway 13 | pom 14 | 15 | 16 | shanjupay-gateway-service 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /shanjupay-gateway/shanjupay-gateway-service/src/main/java/com/shanjupay/gateway/common/util/HttpUtil.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.gateway.common.util; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import com.shanjupay.common.domain.RestResponse; 5 | 6 | import javax.servlet.http.HttpServletResponse; 7 | import java.io.IOException; 8 | 9 | public class HttpUtil { 10 | 11 | public static void writerError(RestResponse restResponse, HttpServletResponse response) throws IOException { 12 | response.setContentType("application/json,charset=utf-8"); 13 | response.setStatus(restResponse.getCode()); 14 | ObjectMapper objectMapper = new ObjectMapper(); 15 | objectMapper.writeValue(response.getOutputStream(),restResponse); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /shanjupay-gateway/shanjupay-gateway-service/src/main/java/com/shanjupay/gateway/config/JWTConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.gateway.config; 2 | 3 | import org.springframework.beans.factory.annotation.Value; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.security.oauth2.provider.token.TokenStore; 7 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 8 | import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; 9 | 10 | @Configuration 11 | public class JWTConfig { 12 | 13 | @Value("${siging-key}") 14 | private String SIGNING_KEY; 15 | 16 | @Bean 17 | public TokenStore tokenStore() { 18 | return new JwtTokenStore(accessTokenConverter()); 19 | } 20 | 21 | @Bean 22 | public JwtAccessTokenConverter accessTokenConverter() { 23 | JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); 24 | converter.setSigningKey(SIGNING_KEY); //对称秘钥,资源服务器使用该秘钥来解密 25 | converter.setAccessTokenConverter(new ClientDefaultAccessTokenConverter()); 26 | return converter; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /shanjupay-gateway/shanjupay-gateway-service/src/main/java/com/shanjupay/gateway/config/RestAccessDeniedHandler.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.gateway.config; 2 | 3 | import com.shanjupay.common.domain.RestResponse; 4 | import com.shanjupay.gateway.common.util.HttpUtil; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.security.access.AccessDeniedException; 7 | import org.springframework.security.web.access.AccessDeniedHandler; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | public class RestAccessDeniedHandler implements AccessDeniedHandler { 15 | @Override 16 | public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException ex) throws IOException, ServletException { 17 | RestResponse restResponse = new RestResponse(HttpStatus.FORBIDDEN.value(),"没有权限"); 18 | HttpUtil.writerError(restResponse,response); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-gateway/shanjupay-gateway-service/src/main/java/com/shanjupay/gateway/config/RestOAuth2AuthExceptionEntryPoint.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.gateway.config; 2 | 3 | import com.shanjupay.common.domain.RestResponse; 4 | import com.shanjupay.gateway.common.util.HttpUtil; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.security.core.AuthenticationException; 7 | import org.springframework.security.oauth2.provider.error.OAuth2AuthenticationEntryPoint; 8 | 9 | import javax.servlet.ServletException; 10 | import javax.servlet.http.HttpServletRequest; 11 | import javax.servlet.http.HttpServletResponse; 12 | import java.io.IOException; 13 | 14 | public class RestOAuth2AuthExceptionEntryPoint extends OAuth2AuthenticationEntryPoint { 15 | @Override 16 | public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) throws IOException, ServletException { 17 | RestResponse restResponse = new RestResponse(HttpStatus.UNAUTHORIZED.value(),e.getMessage()); 18 | HttpUtil.writerError(restResponse,response); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-gateway/shanjupay-gateway-service/src/main/java/com/shanjupay/gateway/config/SecurityConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.gateway.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 5 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 6 | 7 | 8 | @Configuration 9 | public class SecurityConfig extends WebSecurityConfigurerAdapter { 10 | 11 | @Override 12 | protected void configure(HttpSecurity http) throws Exception { 13 | 14 | http 15 | .authorizeRequests() 16 | .antMatchers("/**").permitAll() 17 | .and().csrf().disable(); 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-gateway/shanjupay-gateway-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 56010 #启动端口 命令行注入 3 | max-http-header-size: 100KB 4 | 5 | nacos: 6 | server: 7 | addr: 127.0.0.1:8848 8 | 9 | spring: 10 | application: 11 | name: gateway-service 12 | main: 13 | allow-bean-definition-overriding: true # Spring Boot 2.1 需要设定 14 | cloud: 15 | nacos: 16 | discovery: 17 | server-addr: ${nacos.server.addr} 18 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 19 | cluster-name: DEFAULT 20 | config: 21 | server-addr: ${nacos.server.addr} # 配置中心地址 22 | file-extension: yaml 23 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 24 | group: SHANJUPAY_GROUP # 聚合支付业务组 25 | ext-config: 26 | - 27 | refresh: true 28 | data-id: jwt.yaml # jwt配置 29 | group: COMMON_GROUP # 通用配置组 30 | 31 | 32 | logging: 33 | config: classpath:log4j2.xml 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/MerchantApplicationBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 6 | 7 | @EnableSwagger2 8 | @SpringBootApplication 9 | public class MerchantApplicationBootstrap { 10 | public static void main(String[] args) { 11 | SpringApplication.run(MerchantApplicationBootstrap.class, args); 12 | } 13 | 14 | 15 | } 16 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/common/util/ApplicationContextHelper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.common.util; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class ApplicationContextHelper implements ApplicationContextAware { 10 | private static ApplicationContext applicationContext; 11 | 12 | public ApplicationContextHelper() { 13 | } 14 | 15 | @Override 16 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 17 | ApplicationContextHelper.applicationContext = applicationContext; 18 | } 19 | 20 | public static Object getBean(String beanName) { 21 | return applicationContext != null ? applicationContext.getBean(beanName) : null; 22 | } 23 | 24 | public static T getBean(Class c){ 25 | return applicationContext != null ? applicationContext.getBean(c) : null; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/common/util/LoginUser.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.common.util; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | @Data 9 | public class LoginUser { 10 | private String mobile; 11 | private Map payload = new HashMap<>(); 12 | private String clientId; 13 | private String username; 14 | private Long tenantId; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/config/RestTemplateConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.config; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.context.annotation.Configuration; 5 | import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; 6 | import org.springframework.http.converter.HttpMessageConverter; 7 | import org.springframework.http.converter.StringHttpMessageConverter; 8 | import org.springframework.web.client.RestTemplate; 9 | 10 | import java.nio.charset.StandardCharsets; 11 | import java.util.List; 12 | 13 | @Configuration 14 | public class RestTemplateConfig { 15 | 16 | @Bean 17 | RestTemplate restTemplate(){ 18 | RestTemplate restTemplate = new RestTemplate(new OkHttp3ClientHttpRequestFactory()); 19 | List> messageConverters = restTemplate.getMessageConverters(); 20 | messageConverters.set(1, new StringHttpMessageConverter(StandardCharsets.UTF_8)); 21 | return restTemplate; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.config; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | /** 8 | * @author Administrator 9 | * @version 1.0 10 | **/ 11 | @Component 12 | public class WebMvcConfig implements WebMvcConfigurer { 13 | /** 14 | * 添加静态资源文件,外部可以直接访问地址 15 | * 16 | * @param registry 17 | */ 18 | @Override 19 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 20 | registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); 21 | 22 | registry.addResourceHandler("swagger-ui.html") 23 | .addResourceLocations("classpath:/META-INF/resources/"); 24 | 25 | registry.addResourceHandler("/webjars/**") 26 | .addResourceLocations("classpath:/META-INF/resources/webjars/"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/convert/MerchantDetailConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.convert; 2 | 3 | import com.shanjupay.merchant.api.dto.MerchantDTO; 4 | import com.shanjupay.merchant.vo.MerchantDetailVO; 5 | import com.shanjupay.merchant.vo.MerchantRegisterVO; 6 | import org.mapstruct.Mapper; 7 | import org.mapstruct.factory.Mappers; 8 | 9 | @Mapper 10 | public interface MerchantDetailConvert { 11 | MerchantDetailConvert INSTANCE = Mappers.getMapper(MerchantDetailConvert.class); 12 | 13 | MerchantDTO vo2dto(MerchantDetailVO merchantDetailVO); 14 | 15 | MerchantDetailVO dto2vo(MerchantDTO merchantDTO); 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/convert/MerchantRegisterConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.convert; 2 | 3 | import com.shanjupay.merchant.api.dto.MerchantDTO; 4 | import com.shanjupay.merchant.vo.MerchantRegisterVO; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | /** 9 | * 将商户注册的vo和dto进行转换 10 | */ 11 | @Mapper 12 | public interface MerchantRegisterConvert { 13 | 14 | MerchantRegisterConvert INSTANCE = Mappers.getMapper(MerchantRegisterConvert.class); 15 | 16 | MerchantDTO vo2dto(MerchantRegisterVO merchantRegisterVO); 17 | 18 | MerchantRegisterVO dto2vo(MerchantDTO merchantDTO); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/service/FileService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.service; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | 5 | public interface FileService { 6 | 7 | /** 8 | * 上传文件 9 | * @param bytes 文件字节数组 10 | * @param fileName 数组名 11 | * @return 文件访问路径(url) 12 | * @throws BusinessException 13 | */ 14 | String upload(byte[] bytes, String fileName) throws BusinessException; 15 | } 16 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/service/FileServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.service; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | import com.shanjupay.common.domain.CommonErrorCode; 5 | import com.shanjupay.common.util.QiniuUtils; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.stereotype.Service; 8 | 9 | @Service 10 | public class FileServiceImpl implements FileService { 11 | 12 | @Value("${oss.qiniu.url}") 13 | private String qiniuUrl; 14 | @Value("${oss.qiniu.accessKey}") 15 | private String accessKey; 16 | @Value("${oss.qiniu.secretKey}") 17 | private String secretKey; 18 | @Value("${oss.qiniu.bucket}") 19 | private String bucket; 20 | 21 | /** 22 | * 上传文件 23 | * @param bytes 文件字节数组 24 | * @param fileName 数组名 25 | * @return 26 | * @throws BusinessException 27 | */ 28 | @Override 29 | public String upload(byte[] bytes, String fileName) throws BusinessException { 30 | //调用common下的工具类 31 | try { 32 | QiniuUtils.upload2qiniu(accessKey,secretKey,bucket,bytes,fileName); 33 | } catch (RuntimeException e) { 34 | e.printStackTrace(); 35 | throw new BusinessException(CommonErrorCode.E_100106); 36 | } 37 | //上传成功返回文件的访问地址(绝对路径) 38 | return qiniuUrl+fileName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/service/SmsService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.service; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | 5 | public interface SmsService { 6 | 7 | /** 8 | * 发送手机验证码 9 | * @param phone 手机号 10 | * @return 验证码对应的key 11 | */ 12 | String sendMsg(String phone); 13 | 14 | /** 15 | * 校验验证码 16 | * @param verifyKey 验证码的key 17 | * @param verifyCode 验证码的值 18 | */ 19 | void checkVerifyCode(String verifyKey, String verifyCode) throws BusinessException; 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/vo/MerchantDetailVO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 资质申请 11 | */ 12 | @ApiModel(value = "MerchantDetailVO", description = "商户资质申请") 13 | @Data 14 | public class MerchantDetailVO implements Serializable { 15 | @ApiModelProperty("企业名称") 16 | private String merchantName; 17 | @ApiModelProperty("企业编号") 18 | private String merchantNo; 19 | @ApiModelProperty("企业地址") 20 | private String merchantAddress; 21 | @ApiModelProperty("行业类型") 22 | private String merchantType; 23 | @ApiModelProperty("营业执照") 24 | private String businessLicensesImg; 25 | @ApiModelProperty("法人身份证正面") 26 | private String idCardFrontImg; 27 | @ApiModelProperty("法人身份证反面") 28 | private String idCardAfterImg; 29 | @ApiModelProperty("联系人") 30 | private String username; 31 | @ApiModelProperty("联系人地址") 32 | private String contactsAddress; 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/java/com/shanjupay/merchant/vo/MerchantRegisterVO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 用于接收前端的数据 11 | */ 12 | @ApiModel(value = "MerchantRegisterVO", description = "商户注册信息") 13 | @Data 14 | public class MerchantRegisterVO implements Serializable { 15 | 16 | @ApiModelProperty("商户手机号") 17 | private String mobile; 18 | @ApiModelProperty("商户用户名") 19 | private String username; 20 | @ApiModelProperty("商户密码") 21 | private String password; 22 | @ApiModelProperty("验证码的key") 23 | private String verifiykey; 24 | @ApiModelProperty("验证码") 25 | private String verifiyCode; 26 | } 27 | -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 57010 3 | max‐http‐header‐size: 100KB 4 | nacos: 5 | server: 6 | addr: 127.0.0.1:8848 7 | spring: 8 | application: 9 | name: merchant-application 10 | main: 11 | allow-bean-definition-overriding: true 12 | cloud: 13 | nacos: 14 | discovery: 15 | server-addr: ${nacos.server.addr} 16 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 17 | cluster-name: DEFAULT 18 | config: 19 | server-addr: ${nacos.server.addr} 20 | file-extension: yaml 21 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 22 | group: SHANJUPAY_GROUP 23 | ext-config: 24 | - 25 | refresh: true 26 | data-id: spring-boot-http.yaml 27 | group: COMMON_GROUP 28 | servlet: 29 | multipart: 30 | enabled: true 31 | file-size-threshold: 0 32 | location: 33 | max-file-size: 1MB 34 | max-request-size: 30MB 35 | dubbo: 36 | scan: 37 | base-packages: com.shanjupay 38 | protocol: 39 | name: dubbo 40 | port: 20891 41 | registry: 42 | address: nacos://127.0.0.1:8848 43 | application: 44 | qos-port: 22310 45 | consumer: 46 | check: false 47 | timeout: 3000 48 | retries: -1 49 | cloud: 50 | subscribed-services: merchant-service,transaction-service 51 | logging: 52 | config: classpath:log4j2.xml -------------------------------------------------------------------------------- /shanjupay-merchant-application/src/test/java/com/shanjupay/merchant/TokenTemp.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.shanjupay.common.util.EncryptUtil; 6 | import com.shanjupay.merchant.api.MerchantService; 7 | import com.shanjupay.merchant.api.dto.MerchantDTO; 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.boot.test.context.SpringBootTest; 12 | import org.springframework.test.context.junit4.SpringRunner; 13 | 14 | /** 15 | * @author Administrator 16 | * @version 1.0 17 | **/ 18 | @RunWith(SpringRunner.class) 19 | @SpringBootTest 20 | public class TokenTemp { 21 | 22 | @Autowired 23 | MerchantService merchantService; 24 | 25 | //生成token 26 | @Test 27 | public void createTestToken() { 28 | Long merchantId = 1405390077470789633L;//填写用于测试的商户id 29 | MerchantDTO merchantDTO = merchantService.queryMerchantById(merchantId); 30 | JSONObject token = new JSONObject(); 31 | token.put("mobile", merchantDTO.getMobile()); 32 | token.put("user_name", merchantDTO.getUsername()); 33 | token.put("merchantId", merchantId); 34 | 35 | String jwt_token = "Bearer " + EncryptUtil.encodeBase64(JSON.toJSONString(token).getBytes()); 36 | System.out.println(jwt_token); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /shanjupay-merchant/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-merchant 13 | pom 14 | 15 | shanjupay-merchant-api 16 | shanjupay-merchant-service 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay-merchant 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-merchant-api 13 | 14 | 15 | com.shanjupay 16 | shanjupay-common 17 | 1.0-SNAPSHOT 18 | 19 | 20 | com.fasterxml.jackson.core 21 | jackson-databind 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/src/main/java/com/shanjupay/merchant/api/AppService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.api; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | import com.shanjupay.merchant.api.dto.AppDTO; 5 | 6 | import java.util.List; 7 | 8 | /** 9 | * 应用管理相关接口 10 | */ 11 | public interface AppService { 12 | 13 | /** 14 | * 创建应用 15 | * @param merchantId 商户id 16 | * @param appDTO 应用信息 17 | * @return 创建成功的应用信息 18 | * @throws BusinessException 19 | */ 20 | AppDTO createApp(Long merchantId, AppDTO appDTO) throws BusinessException; 21 | 22 | /** 23 | * 根据商户id查询应用列表 24 | * @param MerchantId 商户id 25 | * @return 应用列表 26 | * @throws BusinessException 27 | */ 28 | List queryAppByMerchant(Long MerchantId) throws BusinessException; 29 | 30 | /** 31 | * 根据应用id查询应用信息 32 | * @param appId 33 | * @return 34 | * @throws BusinessException 35 | */ 36 | AppDTO getAppById(String appId) throws BusinessException; 37 | 38 | /** 39 | * 查询应用是否属于某个商户 40 | * @param appId 41 | * @param merchantId 42 | * @return 43 | */ 44 | Boolean queryAppInMerchant(String appId, Long merchantId); 45 | } 46 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/src/main/java/com/shanjupay/merchant/api/dto/AppDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value="AppDTO", description="") 11 | public class AppDTO implements Serializable { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | private String appId; 16 | 17 | @ApiModelProperty(value = "商店名称") 18 | private String appName; 19 | 20 | @ApiModelProperty(value = "所属商户") 21 | private Long merchantId; 22 | 23 | @ApiModelProperty(value = "应用公钥(RSAWithSHA256)") 24 | private String publicKey; 25 | 26 | @ApiModelProperty(value = "授权回调地址") 27 | private String notifyUrl; 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/src/main/java/com/shanjupay/merchant/api/dto/MerchantDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "MerchantDTO", description = "商户信息") 10 | @Data 11 | public class MerchantDTO implements Serializable { 12 | @ApiModelProperty("商户id") 13 | private Long id; 14 | @ApiModelProperty("企业名称") 15 | private String merchantName; 16 | @ApiModelProperty("企业编号") 17 | private Long merchantNo; 18 | @ApiModelProperty("企业地址") 19 | private String merchantAddress; 20 | @ApiModelProperty("行业类型") 21 | private String merchantType; 22 | @ApiModelProperty("营业执照") 23 | private String businessLicensesImg; 24 | @ApiModelProperty("法人身份证正面") 25 | private String idCardFrontImg; 26 | @ApiModelProperty("法人身份证反面") 27 | private String idCardAfterImg; 28 | @ApiModelProperty("联系人") 29 | private String username; 30 | @ApiModelProperty("密码") 31 | private String password; 32 | @ApiModelProperty("手机号,关联统一账号") 33 | private String mobile; 34 | @ApiModelProperty("联系人地址") 35 | private String contactsAddress; 36 | @ApiModelProperty("审核状态,0‐未申请,1‐已申请待审核,2‐审核通过,3‐审核拒绝") 37 | private String auditStatus; 38 | @ApiModelProperty("租户ID") 39 | private Long tenantId; 40 | } 41 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/src/main/java/com/shanjupay/merchant/api/dto/StaffDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.time.LocalDateTime; 9 | 10 | @Data 11 | @ApiModel(value="StaffDTO", description="") 12 | public class StaffDTO implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | @ApiModelProperty(value = "主键") 17 | private Long id; 18 | 19 | @ApiModelProperty(value = "商户ID") 20 | private Long merchantId; 21 | 22 | @ApiModelProperty(value = "姓名") 23 | private String fullName; 24 | 25 | @ApiModelProperty(value = "职位") 26 | private String position; 27 | 28 | @ApiModelProperty(value = "用户名(关联统一用户)") 29 | private String username; 30 | 31 | @ApiModelProperty(value = "手机号(关联统一用户)") 32 | private String mobile; 33 | 34 | @ApiModelProperty(value = "员工所属门店") 35 | private Long storeId; 36 | 37 | @ApiModelProperty(value = "最后一次登录时间") 38 | private LocalDateTime lastLoginTime; 39 | 40 | @ApiModelProperty(value = "0表示禁用,1表示启用") 41 | private Boolean staffStatus; 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/src/main/java/com/shanjupay/merchant/api/dto/StoreDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.api.dto; 2 | 3 | 4 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 6 | import io.swagger.annotations.ApiModel; 7 | import io.swagger.annotations.ApiModelProperty; 8 | import lombok.Data; 9 | 10 | import java.io.Serializable; 11 | 12 | @Data 13 | @ApiModel(value="StoreDTO", description="") 14 | public class StoreDTO implements Serializable { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @JsonSerialize(using = ToStringSerializer.class) 19 | private Long id; 20 | 21 | @ApiModelProperty(value = "门店名称") 22 | private String storeName; 23 | 24 | @ApiModelProperty(value = "门店编号") 25 | private Long storeNumber; 26 | 27 | @ApiModelProperty(value = "所属商户") 28 | private Long merchantId; 29 | 30 | @ApiModelProperty(value = "父门店") 31 | private Long parentId; 32 | 33 | @ApiModelProperty(value = "0表示禁用,1表示启用") 34 | private Boolean storeStatus; 35 | 36 | @ApiModelProperty(value = "门店地址") 37 | private String storeAddress; 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-api/src/main/java/com/shanjupay/merchant/api/dto/StoreStaffDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value="StoreStaffDTO", description="") 11 | public class StoreStaffDTO implements Serializable { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | private Long id; 16 | 17 | @ApiModelProperty(value = "门店标识") 18 | private Long storeId; 19 | 20 | @ApiModelProperty(value = "员工标识") 21 | private Long staffId; 22 | 23 | 24 | } 25 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/MerchantBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class MerchantBootstrap { 8 | public static void main(String[] args) { 9 | SpringApplication.run(MerchantBootstrap.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor; 5 | import org.mybatis.spring.annotation.MapperScan; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | @Configuration 10 | @MapperScan("com.shanjupay.**.merchant") 11 | public class MybatisPlusConfig { 12 | 13 | /** 14 | * 分页插件,自动是被数据库类型 15 | * @return 16 | */ 17 | @Bean 18 | public PaginationInterceptor paginationInterceptor(){ 19 | return new PaginationInterceptor(); 20 | } 21 | 22 | /** 23 | * 启动性能分析插件 24 | * @return 25 | */ 26 | @Bean 27 | public PerformanceInterceptor performanceInterceptor(){ 28 | return new PerformanceInterceptor(); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/convert/AppConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.convert; 2 | 3 | import com.shanjupay.merchant.api.dto.AppDTO; 4 | import com.shanjupay.merchant.entity.App; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | import org.mapstruct.Mapper; 9 | import org.mapstruct.factory.Mappers; 10 | 11 | import java.io.Serializable; 12 | import java.util.List; 13 | 14 | @Mapper 15 | public interface AppConvert { 16 | AppConvert INSTANCE = Mappers.getMapper(AppConvert.class); 17 | 18 | AppDTO entity2dto(App entity); 19 | 20 | App dto2entity(AppDTO dto); 21 | 22 | List listentity2dto(List app); 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/convert/MerchantConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.convert; 2 | 3 | import com.shanjupay.merchant.api.dto.MerchantDTO; 4 | import com.shanjupay.merchant.entity.Merchant; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | @Mapper 9 | public interface MerchantConvert { 10 | 11 | /** 12 | * 创建转换类实例 13 | */ 14 | MerchantConvert INSTANCE = Mappers.getMapper(MerchantConvert.class); 15 | 16 | /** 17 | * 把dto转换成entity 18 | */ 19 | Merchant dto2entity(MerchantDTO merchantDTO); 20 | 21 | /** 22 | * 把entity转换成dto 23 | */ 24 | MerchantDTO entity2dto(Merchant merchant); 25 | 26 | public static void main(String[] args) { 27 | Merchant merchant = new Merchant(); 28 | merchant.setUsername("text"); 29 | merchant.setMobile("123456"); 30 | MerchantDTO merchantDTO = MerchantConvert.INSTANCE.entity2dto(merchant); 31 | System.out.println(merchantDTO); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/convert/StaffConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.convert; 2 | 3 | import com.shanjupay.merchant.api.dto.StaffDTO; 4 | import com.shanjupay.merchant.entity.Staff; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface StaffConvert { 12 | 13 | StaffConvert INSTANCE = Mappers.getMapper(StaffConvert.class); 14 | 15 | StaffDTO entity2dto(Staff entity); 16 | 17 | Staff dto2entity(StaffDTO dto); 18 | 19 | List listentity2dto(List staff); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/convert/StoreConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.convert; 2 | 3 | import com.shanjupay.merchant.api.dto.StoreDTO; 4 | import com.shanjupay.merchant.entity.Store; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface StoreConvert { 12 | 13 | StoreConvert INSTANCE = Mappers.getMapper(StoreConvert.class); 14 | 15 | StoreDTO entity2dto(Store entity); 16 | 17 | Store dto2entity(StoreDTO dto); 18 | 19 | List listentity2dto(List staff); 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/entity/App.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import java.io.Serializable; 7 | import lombok.Data; 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | 10 | @Data 11 | @TableName("app") 12 | public class App implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | @TableId(value = "ID", type = IdType.ID_WORKER) 17 | private Long id; 18 | 19 | @TableField("APP_ID") 20 | private String appId; 21 | 22 | /** 23 | * 商店名称 24 | */ 25 | @TableField("APP_NAME") 26 | private String appName; 27 | 28 | /** 29 | * 所属商户 30 | */ 31 | @TableField("MERCHANT_ID") 32 | private Long merchantId; 33 | 34 | /** 35 | * 应用公钥(RSAWithSHA256) 36 | */ 37 | @TableField("PUBLIC_KEY") 38 | private String publicKey; 39 | 40 | /** 41 | * 授权回调地址 42 | */ 43 | @TableField("NOTIFY_URL") 44 | private String notifyUrl; 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/entity/Staff.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import java.time.LocalDateTime; 6 | import com.baomidou.mybatisplus.annotation.TableField; 7 | import java.io.Serializable; 8 | import lombok.Data; 9 | import com.baomidou.mybatisplus.annotation.TableName; 10 | 11 | @Data 12 | @TableName("staff") 13 | public class Staff implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | /** 18 | * 主键 19 | */ 20 | @TableId(value = "ID", type = IdType.ID_WORKER) 21 | private Long id; 22 | 23 | /** 24 | * 商户ID 25 | */ 26 | @TableField("MERCHANT_ID") 27 | private Long merchantId; 28 | 29 | /** 30 | * 姓名 31 | */ 32 | @TableField("FULL_NAME") 33 | private String fullName; 34 | 35 | /** 36 | * 职位 37 | */ 38 | @TableField("POSITION") 39 | private String position; 40 | 41 | /** 42 | * 用户名(关联统一用户) 43 | */ 44 | @TableField("USERNAME") 45 | private String username; 46 | 47 | /** 48 | * 手机号(关联统一用户) 49 | */ 50 | @TableField("MOBILE") 51 | private String mobile; 52 | 53 | /** 54 | * 员工所属门店 55 | */ 56 | @TableField("STORE_ID") 57 | private Long storeId; 58 | 59 | /** 60 | * 最后一次登录时间 61 | */ 62 | @TableField("LAST_LOGIN_TIME") 63 | private LocalDateTime lastLoginTime; 64 | 65 | /** 66 | * 0表示禁用,1表示启用 67 | */ 68 | @TableField("STAFF_STATUS") 69 | private Boolean staffStatus; 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/entity/Store.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import java.io.Serializable; 7 | import lombok.Data; 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | 10 | @Data 11 | @TableName("store") 12 | public class Store implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | @TableId(value = "ID", type = IdType.ID_WORKER) 17 | private Long id; 18 | 19 | /** 20 | * 门店名称 21 | */ 22 | @TableField("STORE_NAME") 23 | private String storeName; 24 | 25 | /** 26 | * 门店编号 27 | */ 28 | @TableField("STORE_NUMBER") 29 | private Long storeNumber; 30 | 31 | /** 32 | * 所属商户 33 | */ 34 | @TableField("MERCHANT_ID") 35 | private Long merchantId; 36 | 37 | /** 38 | * 父门店 39 | */ 40 | @TableField("PARENT_ID") 41 | private Long parentId; 42 | 43 | /** 44 | * 0表示禁用,1表示启用 45 | */ 46 | @TableField("STORE_STATUS") 47 | private Boolean storeStatus; 48 | 49 | /** 50 | * 门店地址 51 | */ 52 | @TableField("STORE_ADDRESS") 53 | private String storeAddress; 54 | 55 | 56 | } 57 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/entity/StoreStaff.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableId; 5 | import com.baomidou.mybatisplus.annotation.TableField; 6 | import java.io.Serializable; 7 | import lombok.Data; 8 | import com.baomidou.mybatisplus.annotation.TableName; 9 | 10 | @Data 11 | @TableName("store_staff") 12 | public class StoreStaff implements Serializable { 13 | 14 | private static final long serialVersionUID = 1L; 15 | 16 | @TableId(value = "ID", type = IdType.ID_WORKER) 17 | private Long id; 18 | 19 | /** 20 | * 门店标识 21 | */ 22 | @TableField("STORE_ID") 23 | private Long storeId; 24 | 25 | /** 26 | * 员工标识 27 | */ 28 | @TableField("STAFF_ID") 29 | private Long staffId; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/mapper/AppMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.mapper; 2 | 3 | import com.shanjupay.merchant.entity.App; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2021-06-16 14 | */ 15 | @Repository 16 | public interface AppMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/mapper/MerchantMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.mapper; 2 | 3 | import com.shanjupay.merchant.entity.Merchant; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2021-06-16 14 | */ 15 | @Repository 16 | public interface MerchantMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/mapper/StaffMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.mapper; 2 | 3 | import com.shanjupay.merchant.entity.Staff; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2021-06-16 14 | */ 15 | @Repository 16 | public interface StaffMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/mapper/StoreMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.mapper; 2 | 3 | import com.shanjupay.merchant.entity.Store; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2021-06-16 14 | */ 15 | @Repository 16 | public interface StoreMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/java/com/shanjupay/merchant/mapper/StoreStaffMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.merchant.mapper; 2 | 3 | import com.shanjupay.merchant.entity.StoreStaff; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2021-06-16 14 | */ 15 | @Repository 16 | public interface StoreStaffMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-merchant/shanjupay-merchant-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 57040 3 | max‐http‐header‐size: 100KB 4 | nacos: 5 | server: 6 | addr: 127.0.0.1:8848 7 | spring: 8 | application: 9 | name: merchant-service 10 | main: 11 | allow-bean-definition-overriding: true 12 | cloud: 13 | nacos: 14 | discovery: 15 | server-addr: ${nacos.server.addr} 16 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 17 | cluster-name: DEFAULT 18 | config: 19 | server-addr: ${nacos.server.addr} 20 | file-extension: yaml 21 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 22 | group: SHANJUPAY_GROUP 23 | ext-config: 24 | - refresh: true 25 | data-id: spring-boot-http.yaml 26 | group: COMMON_GROUP 27 | - refresh: true 28 | data-id: spring-boot-starter-druid.yaml 29 | group: COMMON_GROUP 30 | - refresh: true 31 | data-id: spring-boot-mybatis-plus.yaml 32 | group: COMMON_GROUP 33 | 34 | servlet: 35 | multipart: 36 | enabled: true 37 | file-size-threshold: 0 38 | location: 39 | max-file-size: 1MB 40 | max-request-size: 30MB 41 | dubbo: 42 | scan: 43 | base-packages: com.shanjupay 44 | protocol: 45 | name: dubbo 46 | port: 20890 47 | registry: 48 | address: nacos://127.0.0.1:8848 49 | application: 50 | qos-port: 22310 51 | consumer: 52 | check: false 53 | timeout: 90000 54 | retries: -1 55 | cloud: 56 | subscribed-services: merchant-service 57 | logging: 58 | config: classpath:log4j2.xml -------------------------------------------------------------------------------- /shanjupay-payment-agent/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-payment-agent 13 | pom 14 | 15 | shanjupay-payment-agent-api 16 | shanjupay-payment-agent-service 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/PayChannelAgentService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | import com.shanjupay.paymentagent.api.conf.AliConfigParam; 5 | import com.shanjupay.paymentagent.api.dto.AlipayBean; 6 | import com.shanjupay.paymentagent.api.dto.PaymentResponseDTO; 7 | 8 | /** 9 | * 与第三方支付渠道进行交互 10 | */ 11 | public interface PayChannelAgentService { 12 | 13 | /** 14 | * 调用支付宝的下单接口 15 | * @param aliConfigParam 支付渠道的配置参数(支付宝的必要参数) 16 | * @param alipayBean 业务参数(商户订单号,订单标题,订单描述等) 17 | * @return 统一返回PaymentResponseDTO 18 | */ 19 | PaymentResponseDTO createPayOrderByAliWAP(AliConfigParam aliConfigParam, AlipayBean alipayBean) throws BusinessException; 20 | 21 | /** 22 | * 查询支付宝的订单状态 23 | * @param aliConfigParam 支付渠道的参数 24 | * @param outTradeNo 闪聚平台的订单号 25 | * @return 26 | * @throws BusinessException 27 | */ 28 | PaymentResponseDTO queryPayOrderByAli(AliConfigParam aliConfigParam, String outTradeNo) throws BusinessException; 29 | } 30 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/conf/AliConfigParam.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.conf; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class AliConfigParam implements Serializable { 9 | //应用id 10 | public String appId; 11 | //私钥 12 | public String rsaPrivateKey; 13 | //异步回调通知 14 | public String notifyUrl; 15 | //同步回调通知 16 | public String returnUrl; 17 | //支付宝网关 18 | public String url; 19 | //编码方式 UTF-8 20 | public String charest; 21 | //格式JSON 22 | public String format; 23 | //ali公钥 24 | public String alipayPublicKey; 25 | //日志保存路径, 目前不用 26 | public String logPath; 27 | //RSA2 户生成签名字符串所使用的签名算法类型,目前支持RSA2和RSA,推荐使用RSA2 28 | public String signtype; 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/conf/WXConfigParam.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.conf; 2 | 3 | import lombok.Data; 4 | import lombok.NoArgsConstructor; 5 | 6 | import java.io.Serializable; 7 | 8 | 9 | @Data 10 | @NoArgsConstructor 11 | public class WXConfigParam implements Serializable { 12 | 13 | private String appId; 14 | private String appSecret; //是APPID对应的接口密码,用于获取接口调用凭证access_token时使用。 15 | private String mchId; 16 | private String key; 17 | public String returnUrl; 18 | 19 | } 20 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/AlipayBean.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | 4 | import com.fasterxml.jackson.annotation.JsonFormat; 5 | import lombok.Data; 6 | import lombok.ToString; 7 | 8 | import java.io.Serializable; 9 | 10 | /** 11 | * 支付实体对象 12 | * 根据支付宝接口协议 13 | * 14 | */ 15 | @Data 16 | @ToString 17 | public class AlipayBean implements Serializable { 18 | 19 | /** 20 | * 商户订单号,必填 21 | * 22 | */ 23 | private String outTradeNo; 24 | /** 25 | * 订单名称,必填 26 | */ 27 | private String subject; 28 | /** 29 | * 付款金额,必填 30 | */ 31 | private String totalAmount; 32 | 33 | /** 34 | * 产品编号,必填 35 | */ 36 | private String productCode; 37 | /** 38 | * 商品描述,可空 39 | */ 40 | private String body; 41 | /** 42 | * 超时时间参数 43 | */ 44 | private String expireTime; 45 | 46 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") 47 | private String timestamp; 48 | /** 49 | * 门店id 50 | */ 51 | private Long storeId; 52 | 53 | /** 54 | * 订单附件数据, 格式为: SJPAY,平台商户号,Appid,门店,平台渠道编码 55 | */ 56 | private String attach; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/GoodsDetail.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class GoodsDetail implements Serializable { 9 | /** 10 | * 支付宝定义的统一商品编号 11 | */ 12 | private String alipayGoodsId; 13 | 14 | /** 15 | * 商品描述信息 16 | */ 17 | private String body; 18 | 19 | /** 20 | * 商品类目树,从商品类目根节点到叶子节点的类目id组成,类目id值使用|分割 21 | */ 22 | private String categoriesTree; 23 | 24 | /** 25 | * 商品类目 26 | */ 27 | private String goodsCategory; 28 | 29 | /** 30 | * 商品的编号 31 | */ 32 | private String goodsId; 33 | 34 | /** 35 | * 商品名称 36 | */ 37 | private String goodsName; 38 | 39 | /** 40 | * 商品单价,单位为元 41 | */ 42 | private String price; 43 | 44 | /** 45 | * 商品数量 46 | */ 47 | private Long quantity; 48 | 49 | /** 50 | * 商品的展示地址 51 | */ 52 | private String showUrl; 53 | } 54 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/OrderDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.time.LocalDateTime; 7 | 8 | @Data 9 | public class OrderDTO implements Serializable { 10 | 11 | private Long id; 12 | private String tradeNo;//聚合支付订单号 13 | private Long merchantId;//所属商户 14 | private Long storeId;//商户下门店,如果未指定,默认是根门店 15 | private String appId;//此处使用业务id,服务内部使用主键id,服务与服务之间用业务id--appId 16 | private String payChannel;//原始支付渠道编码 17 | private String payChannelMchId;//原始渠道商户id 18 | private String payChannelTradeNo;//原始渠道订单号 19 | private String channel;//聚合支付的渠道 此处使用渠道编码 20 | private String outTradeNo;//商户订单号 21 | private String subject;//商品标题 22 | private String body;//订单描述 23 | private String currency;//币种CNY 24 | private Integer totalAmount;//订单总金额,单位为分 25 | private String optional;//自定义数据 26 | private String analysis;//用于统计分析的数据,用户自定义 27 | private String extra;//特定渠道发起时额外参数 28 | private String tradeState;//交易状态支付状态,0-订单生成,1-支付中(目前未使用),2-支付成功,3-业务处理完成 29 | private String errorCode;//渠道支付错误码 30 | private String errorMsg;//渠道支付错误信息 31 | private String device;//设备 32 | private String clientIp;//客户端IP 33 | private LocalDateTime createTime;//创建时间 34 | private LocalDateTime updateTime;//更新时间 35 | private LocalDateTime expireTime;//订单过期时间 36 | private LocalDateTime paySuccessTime;//支付成功时间 37 | private String openId; 38 | /** 39 | * 原始商家的应用id 40 | */ 41 | private String payChannelMchAppId; 42 | /** 43 | * 产品编号,必填 44 | */ 45 | private String productCode; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/PaymentBillDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.math.BigDecimal; 7 | 8 | @Data 9 | public class PaymentBillDTO implements Serializable { 10 | /*private Long merchantId; 11 | private String merchantName; 12 | private Long merchantAppId;*/ 13 | private String merchantOrderNo; 14 | private String channelOrderNo; 15 | private String productName; 16 | private String createTime; 17 | private String posTime; 18 | private String equipmentNo; 19 | private String userAccount; 20 | private BigDecimal totalAmount; 21 | private BigDecimal tradeAmount; 22 | private BigDecimal discountAmount; 23 | private BigDecimal serviceFee; 24 | private String refundOrderNo; 25 | private BigDecimal refundMoney; 26 | private String platformChannel; 27 | //private String storeId; //自己平台的商户编号,再根据该编号来确认是否是本平台的订单 28 | private String remark; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/TradeCreateResponse.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | /** 9 | * 预支付响应 10 | */ 11 | @Data 12 | @JsonInclude(JsonInclude.Include.NON_NULL) 13 | public class TradeCreateResponse implements Serializable { 14 | 15 | /** 16 | * 原始支付渠道交易号,目前了解的情况是:支付宝直接返回,微信在支付结果通知才给返回 17 | */ 18 | private String payChannelTradeNo; 19 | 20 | /** 21 | * 预支付响应内容 json字符串 22 | */ 23 | private String responseContent; 24 | 25 | 26 | 27 | } 28 | 29 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/TradeStatus.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | public enum TradeStatus { 4 | SUCCESS, // 业务交易支付 明确成功 5 | 6 | FAILED, // 业务交易支付 明确失败, 7 | 8 | UNKNOWN, // 业务交易状态未知, 9 | 10 | USERPAYING, //交易新建,等待支付 11 | 12 | REVOKED, //交易已撤销 13 | } 14 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-api/src/main/java/com/shanjupay/paymentagent/api/dto/WeChatBean.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.api.dto; 2 | 3 | import lombok.Data; 4 | import org.apache.commons.lang.RandomStringUtils; 5 | 6 | import java.io.Serializable; 7 | 8 | @Data 9 | public class WeChatBean implements Serializable { 10 | 11 | private String appid;//公众号 12 | private String mchId;//商户号 13 | private String nonceStr;//随机字符串 14 | private String sign;//签名 15 | private String body;//商品描述 16 | private String outTradeNo;//商户订单号 17 | private Integer totalFee;//标价金额 18 | private String spbillCreateIp;//终端IP 19 | private String notifyUrl;//通知地址 20 | private String tradeType;//交易类型 21 | private String openId; 22 | private Long storeId;//自定义字段,门店id 23 | private String attach;// 附加数据 attach 否 24 | 25 | public String getNonceStr() { 26 | return nonceStr; 27 | } 28 | 29 | public void setNonceStr(String nonceStr) { 30 | nonceStr = RandomStringUtils.random(10, "1234567890"); 31 | this.nonceStr = nonceStr; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-service/logs/${project.name}_error.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dong-ys/shanjupay/66ae1317903b72d949aa7351c0d5b9cd707ba1eb/shanjupay-payment-agent/shanjupay-payment-agent-service/logs/${project.name}_error.log -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-service/src/main/java/com/shanjupay/paymentagent/PaymentAgentBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent; 2 | 3 | 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | public class PaymentAgentBootstrap { 11 | 12 | public static void main(String[] args) { 13 | SpringApplication.run(PaymentAgentBootstrap.class, args); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-service/src/main/java/com/shanjupay/paymentagent/common/AliCodeConstants.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.common; 2 | 3 | /** 4 | * 支付宝查询返回状态码常量类 5 | */ 6 | public class AliCodeConstants { 7 | public static final String SUCCESSCODE = "10000"; // 支付成功或接口调用成功 8 | public static final String PAYINGCODE = "10003"; // 用户支付中 9 | public static final String FAILEDCODE = "40004"; // 失败 10 | public static final String ERRORCODE = "20000"; // 系统异常 11 | 12 | /** 13 | * 支付宝交易状态 14 | * WAIT_BUYER_PAY(交易创建,等待买家付款) 15 | * TRADE_CLOSED(未付款交易超时关闭,或支付完成后全额退款) 16 | * TRADE_SUCCESS(交易支付成功) 17 | * TRADE_FINISHED(交易结束,不可退款) 18 | */ 19 | 20 | public static final String WAIT_BUYER_PAY = "WAIT_BUYER_PAY"; 21 | public static final String TRADE_CLOSED = "TRADE_CLOSED"; 22 | public static final String TRADE_SUCCESS = "TRADE_SUCCESS"; 23 | public static final String TRADE_FINISHED = "TRADE_FINISHED"; 24 | } 25 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-service/src/main/java/com/shanjupay/paymentagent/message/PayProducer.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.paymentagent.message; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.shanjupay.paymentagent.api.dto.PaymentResponseDTO; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.apache.rocketmq.spring.core.RocketMQTemplate; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.messaging.Message; 9 | import org.springframework.messaging.support.MessageBuilder; 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | @Slf4j 14 | public class PayProducer { 15 | 16 | //订单结果查询 17 | private static final String TOPIC_ORDER = "TP_PAYMENT_ORDER"; 18 | //订单结果 19 | private static final String TOPIC_RESULT = "TP_PAYMENT_RESULT"; 20 | 21 | @Autowired 22 | RocketMQTemplate rocketMQTemplate; 23 | 24 | /** 25 | * 发送消息(查询支付宝订单状态的消息) 26 | * @param paymentResponseDTO 27 | */ 28 | public void payOrderNotice(PaymentResponseDTO paymentResponseDTO){ 29 | 30 | Message message = MessageBuilder.withPayload(paymentResponseDTO).build(); 31 | //发送延迟消息(第三级) 32 | rocketMQTemplate.syncSend(TOPIC_ORDER, message, 1000, 3); 33 | log.info("支付渠道代理服务向mq发送订单查询的消息:{}", JSON.toJSONString(paymentResponseDTO)); 34 | } 35 | 36 | /** 37 | * 发送查询结果 38 | * @param paymentResponseDTO 39 | */ 40 | public void payResultNotice(PaymentResponseDTO paymentResponseDTO){ 41 | rocketMQTemplate.convertAndSend(TOPIC_RESULT, paymentResponseDTO); 42 | log.info("支付渠道代理服务向mq发送订单状态:{}", JSON.toJSONString(paymentResponseDTO)); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /shanjupay-payment-agent/shanjupay-payment-agent-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 56070 #启动端口 命令行注入 3 | 4 | nacos: 5 | server: 6 | addr: 127.0.0.1:8848 7 | 8 | spring: 9 | application: 10 | name: payment-agent-service 11 | main: 12 | allow-bean-definition-overriding: true # Spring Boot 2.1 需要设定 13 | cloud: 14 | nacos: 15 | discovery: 16 | server-addr: ${nacos.server.addr} 17 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 18 | cluster-name: DEFAULT 19 | config: 20 | server-addr: ${nacos.server.addr} # 配置中心地址 21 | file-extension: yaml 22 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 23 | group: SHANJUPAY_GROUP # 聚合支付业务组 24 | ext-config: 25 | - 26 | refresh: true 27 | data-id: spring-boot-http.yaml # spring boot http配置 28 | group: COMMON_GROUP # 通用配置组 29 | - 30 | refresh: true 31 | data-id: spring-boot-freemarker.yaml # spring boot freemarker配置 32 | group: COMMON_GROUP # 通用配置组 33 | - 34 | refresh: true 35 | data-id: spring-boot-starter-rocketmq.yaml # rocketmq配置 36 | group: COMMON_GROUP # 通用配置组 37 | 38 | 39 | rocketmq: 40 | nameServer: 127.0.0.1:9876 41 | producer: 42 | group: PID_PAY_PRODUCER 43 | 44 | dubbo: 45 | scan: 46 | # dubbo 服务扫描基准包 47 | base-packages: com.shanjupay 48 | protocol: 49 | # dubbo 协议 50 | name: dubbo 51 | port: 20896 52 | registry: 53 | address: nacos://127.0.0.1:8848 54 | application: 55 | qos: 56 | port: 22270 # dubbo qos端口配置 命令行注入 57 | consumer: 58 | check: false 59 | timeout: 3000 60 | retries: -1 61 | 62 | logging: 63 | config: classpath:log4j2.xml 64 | -------------------------------------------------------------------------------- /shanjupay-transaction/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-transaction 13 | pom 14 | 15 | shanjupay-transaction-api 16 | shanjupay-transaction-service 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/TransactionService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | import com.shanjupay.paymentagent.api.dto.PaymentResponseDTO; 5 | import com.shanjupay.transaction.api.dto.PayOrderDTO; 6 | import com.shanjupay.transaction.api.dto.QRCodeDTO; 7 | 8 | /** 9 | * 交易相关的服务接口 10 | */ 11 | public interface TransactionService { 12 | 13 | /** 14 | * 生成门店二维码URL 15 | * @param qrCodeDTO 传入merchantId,appId,storeId,channel,subject,body 16 | * @return 支付入口(url),将传入的参数转为json,再用base64编码 17 | * @throws BusinessException 18 | */ 19 | String createStoreQRCode(QRCodeDTO qrCodeDTO) throws BusinessException; 20 | 21 | 22 | /** 23 | * 保存支付宝订单接口,1.保存订单到闪聚平台 2.调用支付渠道代理服务调用支付宝的接口 24 | * @param payOrderDTO 25 | * @return 26 | * @throws BusinessException 27 | */ 28 | PaymentResponseDTO submitOrderByAli(PayOrderDTO payOrderDTO) throws BusinessException; 29 | 30 | /** 31 | * 根据订单号查询订单信息 32 | * @param tradeNo 33 | * @return 34 | * @throws BusinessException 35 | */ 36 | public PayOrderDTO queryPayOrder(String tradeNo) throws BusinessException; 37 | 38 | /** 39 | * 更新订单支付状态 40 | * @param tradeNo 闪聚平台订单号 41 | * @param payChannelTradeNo 支付宝或微信的交易流水号(第三方支付系统的订单号) 42 | * @param state 订单状态 交易支付状态 0-订单生成 1-支付中 2-支付完成 4-关闭 5-失败 43 | * @throws BusinessException 44 | */ 45 | void updateOrderTradeNoAndTradeState(String tradeNo, String payChannelTradeNo, String state) throws BusinessException; 46 | } 47 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/dto/OrderResultDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * 订单详细信息 10 | */ 11 | @Data 12 | public class OrderResultDTO implements Serializable { 13 | 14 | private Long id; 15 | private String tradeNo;//聚合支付订单号 16 | private Long merchantId;//所属商户 17 | private Long storeId;//商户下门店,如果未指定,默认是根门店 18 | private String appId;//此处使用业务id,服务内部使用主键id,服务与服务之间用业务id--appId 19 | private String payChannel;//原始支付渠道编码 20 | private String payChannelMchId;//原始渠道商户id 21 | private String payChannelTradeNo;//原始渠道订单号 22 | private String channel;//服务类型 23 | private String outTradeNo;//商户订单号 24 | private String subject;//商品标题 25 | private String body;//订单描述 26 | private String currency;//币种CNY 27 | private Integer totalAmount;//订单总金额,单位为分 28 | private String optional;//自定义数据 29 | private String analysis;//用于统计分析的数据,用户自定义 30 | private String extra;//特定渠道发起时额外参数 31 | private String tradeState;//交易状态支付状态,0-订单生成,1-支付中(目前未使用),2-支付成功,3-业务处理完成 32 | private String errorCode;//渠道支付错误码 33 | private String errorMsg;//渠道支付错误信息 34 | private String device;//设备 35 | private String clientIp;//客户端IP 36 | private LocalDateTime createTime;//创建时间 37 | private LocalDateTime updateTime;//更新时间 38 | private LocalDateTime expireTime;//订单过期时间 39 | private LocalDateTime paySuccessTime;//支付成功时间 40 | private String openId; 41 | /** 42 | * 原始商家的应用id 43 | */ 44 | private String payChannelMchAppId; 45 | /** 46 | * 产品编号,必填 47 | */ 48 | private String productCode; 49 | private String authCode;//付款条码,支付宝或者微信点“付款”产生的付款条码 在b扫c时,应由前端传过来 50 | } 51 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/dto/PayChannelDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "PayChannelDTO", description = "原始第三方支付渠道") 10 | @Data 11 | public class PayChannelDTO implements Serializable { 12 | 13 | private Long id; 14 | /** 15 | * 支付渠道名称 16 | */ 17 | @ApiModelProperty("支付渠道名称") 18 | private String channelName; 19 | /** 20 | * 支付渠道编码 21 | */ 22 | @ApiModelProperty("支付渠道编码") 23 | private String channelCode; 24 | } 25 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/dto/PayChannelParamDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "PayChannelParamDTO", description = "商户原始支付渠道参数配置") 10 | @Data 11 | public class PayChannelParamDTO implements Serializable { 12 | 13 | @ApiModelProperty("参数配置id,新增时无需") 14 | private Long id; 15 | 16 | @ApiModelProperty("应用的appId,是业务id") 17 | private String appId; 18 | 19 | @ApiModelProperty("应用绑定的服务类型对应的code") 20 | private String platformChannelCode; 21 | 22 | @ApiModelProperty("参数配置名称") 23 | private String channelName; 24 | 25 | @ApiModelProperty("商户id") 26 | private Long merchantId; 27 | 28 | @ApiModelProperty("原始支付渠道编码") 29 | private String payChannel; 30 | 31 | @ApiModelProperty("原始支付渠道参数配置内容,json格式") 32 | private String param; 33 | 34 | @ApiModelProperty("应用绑定的服务类型Id") 35 | private Long appPlatformChannelId; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/dto/PayOrderDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.time.LocalDateTime; 7 | 8 | /** 9 | * 下单请求对象 10 | */ 11 | @Data 12 | public class PayOrderDTO implements Serializable { 13 | 14 | private Long merchantId;//商户id 15 | private Long storeId;//商户下门店,如果未指定,默认是根门店 16 | private String appId;//此处使用业务id,服务内部使用主键id,服务与服务之间用业务id--appId 17 | private String channel;//聚合支付的渠道 此处使用渠道编码 18 | private String tradeNo;//聚合支付平台订单号 19 | private String outTradeNo;//商户订单号 20 | private String subject;//商品标题 21 | private String body;//订单描述 22 | private String currency;//币种CNY 23 | private Integer totalAmount;//订单总金额,单位为分 24 | private String optional;//自定义数据 25 | private String analysis;//用于统计分析的数据,用户自定义 26 | private String extra;//特定渠道发起时额外参数 27 | private String openId;//c端付款用户身份标识 28 | private String authCode;//付款条码,支付宝或者微信点“付款”产生的付款条码 在b扫c时,应由前端传过来 29 | private String device;//设备,存放UA等信息 30 | private String clientIp;//客户端id 31 | 32 | private String payChannel;//支付渠道 33 | private String tradeState;//订单状态 34 | 35 | private LocalDateTime createTime;//创建时间 36 | private LocalDateTime updateTime;//更新时间 37 | private LocalDateTime expireTime;//订单过期时间 38 | private LocalDateTime paySuccessTime;//支付成功时间 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/dto/PlatformChannelDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api.dto; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | /** 10 | * 平台提供支付渠道 11 | */ 12 | @ApiModel(value = "PlatformChannelDTO", description = "平台支付渠道") 13 | @Data 14 | public class PlatformChannelDTO implements Serializable { 15 | 16 | @ApiModelProperty("支付渠道ID") 17 | private Long id; 18 | /** 19 | * 支付渠道名称 20 | */ 21 | @ApiModelProperty("支付渠道名称") 22 | private String channelName; 23 | /** 24 | * 支付渠道编码 25 | */ 26 | @ApiModelProperty("支付渠道编码") 27 | private String channelCode; 28 | } 29 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-api/src/main/java/com/shanjupay/transaction/api/dto/QRCodeDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.api.dto; 2 | 3 | 4 | import lombok.Data; 5 | import lombok.NoArgsConstructor; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @NoArgsConstructor 11 | public class QRCodeDTO implements Serializable { 12 | private Long merchantId; 13 | private String appId; 14 | private Long storeId; 15 | private String subject;//商品标题 16 | private String body;//订单描述 17 | } 18 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/logs/${project.name}_error.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dong-ys/shanjupay/66ae1317903b72d949aa7351c0d5b9cd707ba1eb/shanjupay-transaction/shanjupay-transaction-service/logs/${project.name}_error.log -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/TransactionBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | @SpringBootApplication 8 | @EnableDiscoveryClient 9 | public class TransactionBootstrap { 10 | public static void main(String[] args) { 11 | SpringApplication.run(TransactionBootstrap.class,args); 12 | } 13 | } -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor; 5 | import org.mybatis.spring.annotation.MapperScan; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | /** 10 | *

11 | * Mybatis-Plus 配置 12 | *

13 | * 14 | * @author 15 | * @since 2019-07-15 16 | */ 17 | @Configuration 18 | @MapperScan("com.shanjupay.**.mapper") 19 | public class MybatisPlusConfig { 20 | 21 | /** 22 | * 分页插件,自动识别数据库类型 23 | */ 24 | @Bean 25 | public PaginationInterceptor paginationInterceptor() { 26 | return new PaginationInterceptor(); 27 | } 28 | 29 | /** 30 | * 启用性能分析插件 31 | */ 32 | @Bean 33 | public PerformanceInterceptor performanceInterceptor(){ 34 | return new PerformanceInterceptor(); 35 | } 36 | } -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.config; 2 | 3 | import com.shanjupay.common.cache.Cache; 4 | import com.shanjupay.transaction.common.util.RedisCache; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.context.annotation.Configuration; 7 | import org.springframework.data.redis.core.StringRedisTemplate; 8 | 9 | @Configuration 10 | public class RedisConfig { 11 | 12 | @Bean 13 | public Cache cache(StringRedisTemplate stringRedisTemplate){ 14 | return new RedisCache(stringRedisTemplate); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.config; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | @Configuration 16 | @ConditionalOnProperty(prefix = "swagger",value = {"enable"},havingValue = "true") 17 | @EnableSwagger2 18 | public class SwaggerConfiguration { 19 | 20 | @Bean 21 | public Docket buildDocket() { 22 | return new Docket(DocumentationType.SWAGGER_2) 23 | .apiInfo(buildApiInfo()) 24 | .select() 25 | // 要扫描的API(Controller)基础包 26 | .apis(RequestHandlerSelectors.basePackage("com.shanjupay.transaction.controller")) 27 | .paths(PathSelectors.any()) 28 | .build(); 29 | } 30 | 31 | /** 32 | * @param 33 | * @return springfox.documentation.service.ApiInfo 34 | * @Title: 构建API基本信息 35 | * @methodName: buildApiInfo 36 | */ 37 | private ApiInfo buildApiInfo() { 38 | Contact contact = new Contact("开发者","",""); 39 | return new ApiInfoBuilder() 40 | .title("API文档") 41 | .description("") 42 | .contact(contact) 43 | .version("1.0.0").build(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/config/WebMvcConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.config; 2 | 3 | import org.springframework.stereotype.Component; 4 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | @Component 8 | public class WebMvcConfig implements WebMvcConfigurer { 9 | @Override 10 | public void addViewControllers(ViewControllerRegistry registry) { 11 | registry.addViewController("/pay-page").setViewName("pay"); 12 | registry.addViewController("/pay-page-error").setViewName("pay_error"); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/controller/BrowserType.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.controller; 2 | 3 | /** 4 | * 浏览器类型 5 | */ 6 | public enum BrowserType { 7 | ALIPAY,//支付宝 8 | WECHAT,//微信 9 | PC_BROWSER,//pc端浏览器 10 | MOBILE_BROWSER; //手机端浏览器 11 | 12 | 13 | /** 14 | * 根据UA获取浏览器类型 15 | * @param userAgent userAgent 16 | * @return 浏览器类型 17 | */ 18 | public static BrowserType valueOfUserAgent(String userAgent) { 19 | if (userAgent != null && userAgent.contains("AlipayClient")) { 20 | return BrowserType.ALIPAY; 21 | }else if (userAgent != null && userAgent.contains("MicroMessenger")) { 22 | return BrowserType.WECHAT; 23 | }else{ 24 | return BrowserType.MOBILE_BROWSER; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/convert/OrderResultConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.convert; 2 | 3 | import com.shanjupay.transaction.api.dto.OrderResultDTO; 4 | import com.shanjupay.transaction.entity.PayOrder; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | @Mapper 9 | public interface OrderResultConvert { 10 | 11 | OrderResultConvert INSTANCE = Mappers.getMapper(OrderResultConvert.class); 12 | 13 | OrderResultDTO entity2dto(PayOrder entity); 14 | 15 | PayOrder dto2entity(OrderResultDTO dto); 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/convert/PayChannelParamConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.convert; 2 | 3 | import com.shanjupay.transaction.api.dto.PayChannelParamDTO; 4 | import com.shanjupay.transaction.entity.PayChannelParam; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.Mapping; 7 | import org.mapstruct.Mappings; 8 | import org.mapstruct.factory.Mappers; 9 | 10 | import java.util.List; 11 | 12 | @Mapper 13 | public interface PayChannelParamConvert { 14 | 15 | PayChannelParamConvert INSTANCE= Mappers.getMapper(PayChannelParamConvert.class); 16 | 17 | PayChannelParamDTO entity2dto(PayChannelParam entity); 18 | 19 | PayChannelParam dto2entity(PayChannelParamDTO dto); 20 | 21 | List listentity2listdto(List PlatformChannel); 22 | 23 | List listdto2listentity(List PlatformChannelDTO); 24 | } 25 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/convert/PayOrderConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.convert; 2 | 3 | import com.shanjupay.transaction.api.dto.PayOrderDTO; 4 | import com.shanjupay.transaction.entity.PayOrder; 5 | import com.shanjupay.transaction.vo.OrderConfirmVO; 6 | import org.mapstruct.Mapper; 7 | import org.mapstruct.Mapping; 8 | import org.mapstruct.factory.Mappers; 9 | 10 | @Mapper 11 | public interface PayOrderConvert { 12 | 13 | PayOrderConvert INSTANCE = Mappers.getMapper(PayOrderConvert.class); 14 | 15 | PayOrderDTO entity2dto(PayOrder entity); 16 | 17 | PayOrder dto2entity(PayOrderDTO dto); 18 | 19 | //忽略totalAmount,不做映射 20 | @Mapping(target = "totalAmount", ignore = true) 21 | PayOrderDTO vo2dto(OrderConfirmVO vo); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/convert/PlatformChannelConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.convert; 2 | 3 | import com.shanjupay.transaction.api.dto.PlatformChannelDTO; 4 | import com.shanjupay.transaction.entity.PlatformChannel; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface PlatformChannelConvert { 12 | 13 | PlatformChannelConvert INSTANCE = Mappers.getMapper(PlatformChannelConvert.class); 14 | 15 | PlatformChannelDTO entity2dto(PlatformChannel entity); 16 | 17 | PlatformChannel dto2entity(PlatformChannelDTO dto); 18 | 19 | List listentity2listdto(List PlatformChannel); 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/entity/AppPlatformChannel.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @TableName("app_platform_channel") 13 | public class AppPlatformChannel implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @TableId(value = "ID", type = IdType.ID_WORKER) 18 | private Long id; 19 | 20 | /** 21 | * 应用id 22 | */ 23 | @TableField("APP_ID") 24 | private String appId; 25 | 26 | /** 27 | * 平台支付渠道 28 | */ 29 | @TableField("PLATFORM_CHANNEL") 30 | private String platformChannel; 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/entity/PayChannel.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @TableName("pay_channel") 13 | public class PayChannel implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @TableId(value = "ID", type = IdType.ID_WORKER) 18 | private Long id; 19 | 20 | /** 21 | * 原始支付渠道名称 22 | */ 23 | @TableField("CHANNEL_NAME") 24 | private String channelName; 25 | 26 | /** 27 | * 原始支付渠道编码 28 | */ 29 | @TableField("CHANNEL_CODE") 30 | private String channelCode; 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/entity/PayChannelParam.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @TableName("pay_channel_param") 13 | public class PayChannelParam implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @TableId(value = "ID", type = IdType.ID_WORKER) 18 | private Long id; 19 | 20 | /** 21 | * 配置名称 22 | */ 23 | @TableField("CHANNEL_NAME") 24 | private String channelName; 25 | 26 | /** 27 | * 商户ID 28 | */ 29 | @TableField("MERCHANT_ID") 30 | private Long merchantId; 31 | 32 | /** 33 | * 原始支付渠道编码 34 | */ 35 | @TableField("PAY_CHANNEL") 36 | private String payChannel; 37 | 38 | /** 39 | * 支付参数 40 | */ 41 | @TableField("PARAM") 42 | private String param; 43 | 44 | /** 45 | * 应用与支付渠道绑定ID 46 | */ 47 | @TableField("APP_PLATFORM_CHANNEL_ID") 48 | private Long appPlatformChannelId; 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/entity/PlatformChannel.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @TableName("platform_channel") 13 | public class PlatformChannel implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @TableId(value = "ID", type = IdType.ID_WORKER) 18 | private Long id; 19 | 20 | /** 21 | * 平台支付渠道名称 22 | */ 23 | @TableField("CHANNEL_NAME") 24 | private String channelName; 25 | 26 | /** 27 | * 平台支付渠道编码 28 | */ 29 | @TableField("CHANNEL_CODE") 30 | private String channelCode; 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/entity/PlatformPayChannel.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | @Data 12 | @TableName("platform_pay_channel") 13 | public class PlatformPayChannel implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @TableId(value = "ID", type = IdType.ID_WORKER) 18 | private Long id; 19 | 20 | /** 21 | * 平台支付渠道编码 22 | */ 23 | @TableField("PLATFORM_CHANNEL") 24 | private String platformChannel; 25 | 26 | /** 27 | * 原始支付渠道名称 28 | */ 29 | @TableField("PAY_CHANNEL") 30 | private String payChannel; 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/AppPlatformChannelMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.AppPlatformChannel; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * 说明了应用选择了平台中的哪些支付渠道 Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface AppPlatformChannelMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/AppPlatformChannelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PayChannelMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.PayChannel; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface PayChannelMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PayChannelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PayChannelParamMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.PayChannelParam; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * 某商户针对某一种原始支付渠道的配置参数 Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface PayChannelParamMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PayChannelParamMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PayOrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.PayOrder; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface PayOrderMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PayOrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PaymentBillMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.PaymentBill; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface PaymentBillMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PaymentBillMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PlatformChannelMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.api.dto.PayChannelDTO; 5 | import com.shanjupay.transaction.entity.PayChannel; 6 | import com.shanjupay.transaction.entity.PlatformChannel; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | *

14 | * Mapper 接口 15 | *

16 | * 17 | * @author author 18 | * @since 2019-11-15 19 | */ 20 | @Repository 21 | public interface PlatformChannelMapper extends BaseMapper { 22 | 23 | /** 24 | * 根据服务类型code查询对应的支付渠道 25 | * @param platformChannel 26 | * @return 27 | */ 28 | @Select("select\n" + 29 | "pc.*\n" + 30 | "from\n" + 31 | "platform_pay_channel ppc,\n" + 32 | "pay_channel pc,\n" + 33 | "platform_channel pla\n" + 34 | "where ppc.PAY_CHANNEL = pc.CHANNEL_CODE\n" + 35 | "and ppc.PLATFORM_CHANNEL = pla.CHANNEL_CODE\n" + 36 | "and pla.CHANNEL_CODE = #{platformChannel}") 37 | List selectPayChannelByPlatformChannel(String platformChannel); 38 | } 39 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PlatformChannelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PlatformPayChannelMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.PlatformPayChannel; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface PlatformPayChannelMapper extends BaseMapper { 17 | 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/PlatformPayChannelMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/RefundOrderMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.transaction.entity.RefundOrder; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * @author author 13 | * @since 2019-11-15 14 | */ 15 | @Repository 16 | public interface RefundOrderMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/mapper/RefundOrderMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/main/java/com/shanjupay/transaction/vo/OrderConfirmVO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction.vo; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import lombok.Data; 5 | 6 | @ApiModel(value = "OrderConfirmVO", description = "订单确认信息") 7 | @Data 8 | public class OrderConfirmVO { 9 | private String appId; //应用id 10 | private String tradeNo;//交易单号 11 | private String openId;//微信openid 12 | private String storeId;//门店id 13 | private String channel; //服务类型 14 | private String body;//订单描述 15 | private String subject;//订单标题 16 | private String totalAmount;//金额 17 | } 18 | -------------------------------------------------------------------------------- /shanjupay-transaction/shanjupay-transaction-service/src/test/java/com/shanjupay/transaction/TestPayChannelService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.transaction; 2 | 3 | import com.shanjupay.transaction.api.PayChannelService; 4 | import com.shanjupay.transaction.api.dto.PayChannelDTO; 5 | import org.junit.Test; 6 | import org.junit.runner.RunWith; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | import org.springframework.test.context.junit4.SpringRunner; 10 | 11 | import java.util.List; 12 | 13 | @SpringBootTest 14 | @RunWith(SpringRunner.class) 15 | public class TestPayChannelService { 16 | 17 | @Autowired 18 | PayChannelService payChannelService; 19 | 20 | //根据服务类型查询支付渠道 21 | @Test 22 | public void testQueryPayChannelByPlatformChannel(){ 23 | List shanju_c2b = payChannelService.queryPayChannelByPlatformChannel("shanju_c2b"); 24 | System.out.println(shanju_c2b.toString()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /shanjupay-uaa/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-uaa 13 | pom 14 | 15 | 16 | shanjupay-uaa-api 17 | shanjupay-uaa-service 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-api/src/main/java/com/shanjupay/uua/api/ClientDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uua.api; 2 | 3 | public interface ClientDetailsService { 4 | 5 | 6 | /** 7 | * 创建接入客户端,用于用户中心应用的关联创建 8 | */ 9 | void createClientDetails(); 10 | } 11 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-api/src/main/java/com/shanjupay/uua/api/OauthClientDetailsService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uua.api; 2 | 3 | import java.util.Map; 4 | 5 | public interface OauthClientDetailsService { 6 | 7 | public void createClientDetails(Map map); 8 | 9 | /** 10 | * 根据appId查询 client信息 appId也就是client_id 11 | * @param appId 12 | * @return 13 | */ 14 | public Map getClientDetailsByClientId(String appId); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-api/src/main/java/com/shanjupay/uua/api/dto/MerchantLoginDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uua.api.dto; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | import java.util.Map; 7 | 8 | @Data 9 | public class MerchantLoginDTO implements Serializable { 10 | 11 | //@RequestParam("name")String name, 12 | //@RequestBody Map payload, 13 | //@RequestParam("effectiveTime")int effectiveTime 14 | private String mobile; 15 | 16 | private String name; 17 | 18 | private Map payload; 19 | 20 | private int effectiveTime; 21 | } 22 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/UAABootstrap.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | 7 | 8 | @SpringBootApplication 9 | @EnableDiscoveryClient 10 | public class UAABootstrap { 11 | 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(UAABootstrap.class, args); 15 | 16 | } 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/common/utils/ApplicationContextHelper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.common.utils; 2 | 3 | import org.springframework.beans.BeansException; 4 | import org.springframework.context.ApplicationContext; 5 | import org.springframework.context.ApplicationContextAware; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public class ApplicationContextHelper implements ApplicationContextAware { 10 | private static ApplicationContext applicationContext; 11 | 12 | public ApplicationContextHelper() { 13 | } 14 | 15 | @Override 16 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 17 | ApplicationContextHelper.applicationContext = applicationContext; 18 | } 19 | 20 | public static Object getBean(String beanName) { 21 | return applicationContext != null?applicationContext.getBean(beanName):null; 22 | } 23 | 24 | public static Object getBean(Class clazz) { 25 | return applicationContext != null?applicationContext.getBean(clazz):null; 26 | } 27 | } 28 | 29 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/common/utils/GuidGenerator.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.common.utils; 2 | 3 | import org.springframework.security.oauth2.common.util.RandomValueStringGenerator; 4 | 5 | import java.util.UUID; 6 | 7 | public abstract class GuidGenerator { 8 | 9 | 10 | private static RandomValueStringGenerator defaultClientSecretGenerator = new RandomValueStringGenerator(32); 11 | 12 | 13 | /** 14 | * private constructor 15 | */ 16 | private GuidGenerator() { 17 | } 18 | 19 | public static String generate() { 20 | return UUID.randomUUID().toString().replaceAll("-", ""); 21 | } 22 | 23 | public static String generateClientSecret() { 24 | return defaultClientSecretGenerator.generate(); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/common/utils/WebUtils.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.common.utils; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | import javax.servlet.http.HttpServletRequest; 6 | 7 | 8 | public class WebUtils { 9 | 10 | 11 | public static final String UTF_8 = "UTF-8"; 12 | 13 | 14 | 15 | public static final String VERSION = "2.0.1"; 16 | 17 | 18 | private static ThreadLocal ipThreadLocal = new ThreadLocal<>(); 19 | 20 | 21 | public static void setIp(String ip) { 22 | ipThreadLocal.set(ip); 23 | } 24 | 25 | public static String getIp() { 26 | return ipThreadLocal.get(); 27 | } 28 | 29 | //private 30 | private WebUtils() { 31 | } 32 | 33 | 34 | /** 35 | * Retrieve client ip address 36 | * 37 | * @param request HttpServletRequest 38 | * @return IP 39 | */ 40 | public static String retrieveClientIp(HttpServletRequest request) { 41 | String ip = request.getHeader("x-forwarded-for"); 42 | if (isUnAvailableIp(ip)) { 43 | ip = request.getHeader("Proxy-Client-IP"); 44 | } 45 | if (isUnAvailableIp(ip)) { 46 | ip = request.getHeader("WL-Proxy-Client-IP"); 47 | } 48 | if (isUnAvailableIp(ip)) { 49 | ip = request.getRemoteAddr(); 50 | } 51 | return ip; 52 | } 53 | 54 | private static boolean isUnAvailableIp(String ip) { 55 | return StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip); 56 | } 57 | 58 | } -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/config/JWTConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.config; 2 | 3 | import com.shanjupay.uaa.integration.ClientDefaultAccessTokenConverter; 4 | import com.shanjupay.uaa.integration.UnifiedUserAuthenticationConverter; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.security.oauth2.provider.token.TokenStore; 9 | import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter; 10 | import org.springframework.security.oauth2.provider.token.store.JwtTokenStore; 11 | 12 | @Configuration 13 | public class JWTConfig { 14 | 15 | @Value("${siging-key}") 16 | private String SIGNING_KEY; 17 | 18 | @Bean 19 | public TokenStore tokenStore() { 20 | return new JwtTokenStore(accessTokenConverter()); 21 | } 22 | 23 | @Bean 24 | public JwtAccessTokenConverter accessTokenConverter() { 25 | JwtAccessTokenConverter converter = new JwtAccessTokenConverter(); 26 | converter.setSigningKey(SIGNING_KEY); //对称秘钥,资源服务器使用该秘钥来解密 27 | ClientDefaultAccessTokenConverter accessTokenConverter = new ClientDefaultAccessTokenConverter(); 28 | accessTokenConverter.setUserTokenConverter(new UnifiedUserAuthenticationConverter()); 29 | converter.setAccessTokenConverter(accessTokenConverter); 30 | return converter; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/config/WebConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; 5 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 6 | 7 | 8 | /** 9 | * Spring servlet Context的配置 10 | */ 11 | @Configuration 12 | public class WebConfig implements WebMvcConfigurer { 13 | 14 | @Override 15 | public void addViewControllers(ViewControllerRegistry registry) { 16 | registry.addViewController("/login").setViewName("login"); 17 | registry.addViewController("/confirm_access").setViewName("oauth_approval"); 18 | registry.addViewController("/oauth_error").setViewName("oauth_error"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/domain/AuthPrincipal.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.domain; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | @Data 9 | public class AuthPrincipal { 10 | private String username; //用户名 11 | private String domain; //域 用于扩展 12 | private String authenticationType; // 认证的类型 password:用户名密码模式类型 sms:短信模式类型 13 | private Map payload = new HashMap<>();//附加数据,不同认证类型可拥有不同的附加数据。如认证类型为短信时包含smsKey : sms:3d21042d054548b08477142bbca95cfa; 所有情况下都包含clientId 14 | 15 | } 16 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/integration/RestOAuth2Exception.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.integration; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonSerialize; 4 | import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; 5 | 6 | @JsonSerialize(using = RestOAuthExceptionJacksonSerializer.class) 7 | public class RestOAuth2Exception extends OAuth2Exception { 8 | 9 | public RestOAuth2Exception(String msg, Throwable t) { 10 | super(msg, t); 11 | } 12 | 13 | public RestOAuth2Exception(String msg) { 14 | super(msg); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/integration/RestOAuthExceptionJacksonSerializer.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.integration; 2 | 3 | import com.fasterxml.jackson.core.JsonGenerator; 4 | import com.fasterxml.jackson.databind.SerializerProvider; 5 | import com.fasterxml.jackson.databind.ser.std.StdSerializer; 6 | import org.springframework.web.util.HtmlUtils; 7 | 8 | import java.io.IOException; 9 | import java.util.Map; 10 | 11 | public class RestOAuthExceptionJacksonSerializer extends StdSerializer { 12 | 13 | protected RestOAuthExceptionJacksonSerializer() { 14 | super(RestOAuth2Exception.class); 15 | } 16 | 17 | @Override 18 | public void serialize(RestOAuth2Exception value, JsonGenerator jgen, SerializerProvider serializerProvider) throws IOException { 19 | jgen.writeStartObject(); 20 | jgen.writeObjectField("errCode", value.getHttpErrorCode()); 21 | String errorMessage = value.getOAuth2ErrorCode(); 22 | if (errorMessage != null) { 23 | errorMessage = HtmlUtils.htmlEscape(errorMessage); 24 | } 25 | jgen.writeStringField("errMessage", value.getMessage()); 26 | //jgen.writeStringField("errMessage", errorMessage); 27 | //String summary = value.getSummary(); 28 | //jgen.writeStringField("result", summary); 29 | 30 | if (value.getAdditionalInformation()!=null) { 31 | for (Map.Entry entry : value.getAdditionalInformation().entrySet()) { 32 | String key = entry.getKey(); 33 | String add = entry.getValue(); 34 | jgen.writeStringField(key, add); 35 | } 36 | } 37 | jgen.writeEndObject(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/java/com/shanjupay/uaa/repository/OauthRepository.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.uaa.repository; 2 | 3 | 4 | import com.shanjupay.uaa.domain.OauthClientDetails; 5 | 6 | import java.util.List; 7 | 8 | public interface OauthRepository { 9 | 10 | OauthClientDetails findOauthClientDetails(String clientId); 11 | 12 | List findAllOauthClientDetails(); 13 | 14 | void updateOauthClientDetailsArchive(String clientId, boolean archive); 15 | 16 | void saveOauthClientDetails(OauthClientDetails clientDetails); 17 | 18 | 19 | } -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 56020 #启动端口 命令行注入 3 | max-http-header-size: 100KB 4 | 5 | nacos: 6 | server: 7 | addr: 127.0.0.1:8848 8 | 9 | spring: 10 | application: 11 | name: uaa-service 12 | main: 13 | allow-bean-definition-overriding: true # Spring Boot 2.1 需要设定 14 | cloud: 15 | nacos: 16 | discovery: 17 | server-addr: ${nacos.server.addr} 18 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 19 | cluster-name: DEFAULT 20 | config: 21 | server-addr: ${nacos.server.addr} # 配置中心地址 22 | file-extension: yaml 23 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 24 | group: SHANJUPAY_GROUP # 聚合支付业务组 25 | ext-config: 26 | - 27 | refresh: true 28 | data-id: spring-boot-http.yaml # spring boot http配置 29 | group: COMMON_GROUP # 通用配置组 30 | - 31 | refresh: true 32 | data-id: spring-boot-starter-druid.yaml # spring boot starter druid配置 33 | group: COMMON_GROUP # 通用配置组 34 | - 35 | refresh: true 36 | data-id: jwt.yaml # jwt配置 37 | group: COMMON_GROUP # 通用配置组 38 | 39 | dubbo: 40 | scan: 41 | # dubbo 服务扫描基准包 42 | base-packages: com.shanjupay 43 | protocol: 44 | # dubbo 协议 45 | name: dubbo 46 | port: 20881 47 | registry: 48 | address: nacos://127.0.0.1:8848 49 | application: 50 | qos: 51 | port: 22220 # dubbo qos端口配置 命令行注入 52 | consumer: 53 | check: false 54 | timeout: 3000 55 | retries: -1 56 | 57 | logging: 58 | config: classpath:log4j2.xml 59 | 60 | -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/resources/static/img/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dong-ys/shanjupay/66ae1317903b72d949aa7351c0d5b9cd707ba1eb/shanjupay-uaa/shanjupay-uaa-service/src/main/resources/static/img/error.png -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/resources/static/img/password.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dong-ys/shanjupay/66ae1317903b72d949aa7351c0d5b9cd707ba1eb/shanjupay-uaa/shanjupay-uaa-service/src/main/resources/static/img/password.png -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/resources/static/img/username.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dong-ys/shanjupay/66ae1317903b72d949aa7351c0d5b9cd707ba1eb/shanjupay-uaa/shanjupay-uaa-service/src/main/resources/static/img/username.png -------------------------------------------------------------------------------- /shanjupay-uaa/shanjupay-uaa-service/src/main/resources/templates/oauth_error.html: -------------------------------------------------------------------------------- 1 | <#import "/spring.ftl" as spring/> 2 | 3 | 4 | 5 | 授权失败 6 | 11 | 12 | 13 | 14 | 15 |
16 | 授权失败 17 |

sorry

18 |

不小心出错啦!

19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /shanjupay-user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | shanjupay 7 | com.shanjupay 8 | 1.0-SNAPSHOT 9 | 10 | 4.0.0 11 | 12 | shanjupay-user 13 | pom 14 | 15 | shanjupay-user-api 16 | shanjupay-user-service 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/MenuService.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api; 2 | 3 | import com.shanjupay.common.domain.BusinessException; 4 | import com.shanjupay.common.domain.PageVO; 5 | import com.shanjupay.user.api.dto.menu.MenuDTO; 6 | import com.shanjupay.user.api.dto.menu.MenuQueryDTO; 7 | 8 | import java.util.List; 9 | 10 | /** 11 | * 菜单服务 12 | * 菜单为手工建立维护 13 | */ 14 | public interface MenuService { 15 | 16 | /** 17 | * 根据ID查询菜单 18 | * @param id 19 | * @return 20 | */ 21 | MenuDTO queryMenu(Long id) throws BusinessException; 22 | 23 | /** 24 | * 根据应用编码查询菜单列表 25 | * @param applicationCode 26 | * @return 27 | */ 28 | List queryMenuByApplicationCode(String applicationCode) throws BusinessException; 29 | /** 30 | * 根据条件查询菜单列表 31 | * @param params 32 | * @param pageSize 33 | * @param pageNo 34 | */ 35 | PageVO queryMenu(MenuQueryDTO params, Integer pageNo, Integer pageSize) throws BusinessException; 36 | 37 | /** 38 | * 根据权限编码列表获取菜单 39 | * @param privileges 权限列表 40 | * @return 41 | */ 42 | List queryMenuByPrivileges(String [] privileges) throws BusinessException; 43 | 44 | 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/authorization/AuthorizationInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.authorization; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | /** 13 | * 授权信息 14 | */ 15 | @Data 16 | @ApiModel(value = "AuthorizationInfoDTO", description = "授权信息,包括角色与权限") 17 | public class AuthorizationInfoDTO implements Serializable { 18 | 19 | /*private List roleCodes = new ArrayList<>();//角色编码集合 20 | 21 | private List privilegeCodes = new ArrayList<>(); //权限编码集合 22 | */ 23 | @ApiModelProperty("授权信息,角色-权限关系,key为角色编码,value为权限集合") //rolecode [pcode1,pcode2] 24 | private Map> rolePrivilegeMap = new HashMap<>();//角色-权限列表 映射 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/authorization/PrivilegeDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.authorization; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | 10 | @ApiModel(value = "PrivilegeDTO", description = "权限信息") 11 | @Data 12 | public class PrivilegeDTO implements Serializable { 13 | 14 | 15 | @ApiModelProperty("权限id") 16 | private Long id; 17 | 18 | @ApiModelProperty("权限名称") 19 | private String name; 20 | 21 | @ApiModelProperty("权限编码") 22 | private String code; 23 | 24 | @ApiModelProperty("所属权限组id") 25 | private Long privilegeGroupId; 26 | 27 | } -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/authorization/PrivilegeGroupDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.authorization; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value = "PrivilegeGroupDTO", description = "权限组信息") 11 | public class PrivilegeGroupDTO implements Serializable { 12 | 13 | @ApiModelProperty("权限组id") 14 | private Long id; 15 | 16 | @ApiModelProperty("权限组父id") 17 | private Long parentId; 18 | 19 | @ApiModelProperty("权限组名称") 20 | private String name; 21 | 22 | @ApiModelProperty("排序") 23 | private Integer sort; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/authorization/PrivilegeTreeDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.authorization; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | /** 12 | * 权限树结构 13 | */ 14 | @Data 15 | @ApiModel(value = "PrivilegeTreeDTO", description = "权限树信息") 16 | public class PrivilegeTreeDTO implements Serializable { 17 | 18 | /** 19 | * 权限组使用id,权限使用code,约束code不能为纯数值保证不重复 20 | */ 21 | @ApiModelProperty("节点唯一标识,权限组使用id,权限使用code,约束code不能为纯数值保证不重复。") 22 | private String id; 23 | 24 | @ApiModelProperty("节点名称") 25 | private String name; 26 | 27 | /** 28 | * 一定是权限组id,权限没有结构 29 | */ 30 | @ApiModelProperty("父节点标识") 31 | private String parentId;//父级id 32 | 33 | @ApiModelProperty("排序") 34 | private Integer sort;// 同层排序,不排序都为0 35 | 36 | @ApiModelProperty("状态") 37 | private Integer status;//状态 38 | 39 | @ApiModelProperty("是否为权限组") 40 | private boolean isGroup = true; //显示名称 41 | 42 | @ApiModelProperty("子节点集合") 43 | private List children = new ArrayList<>(); 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/authorization/RoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.authorization; 2 | 3 | 4 | import io.swagger.annotations.ApiModel; 5 | import io.swagger.annotations.ApiModelProperty; 6 | import lombok.Data; 7 | 8 | import java.io.Serializable; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | 12 | /** 13 | * 角色信息 14 | */ 15 | @ApiModel(value = "RoleDTO", description = "角色信息") 16 | @Data 17 | public class RoleDTO implements Serializable { 18 | 19 | 20 | @ApiModelProperty("角色id") 21 | private Long id; 22 | /** 23 | * 角色名称 24 | */ 25 | 26 | @ApiModelProperty("角色名称") 27 | private String name; 28 | 29 | /** 30 | * 角色编码 31 | */ 32 | 33 | @ApiModelProperty("角色编码") 34 | private String code; 35 | 36 | /** 37 | * 角色所属租户 38 | */ 39 | 40 | @ApiModelProperty("角色所属租户") 41 | private Long tenantId; 42 | 43 | /** 44 | * 角色包含权限列表 45 | */ 46 | 47 | @ApiModelProperty("角色包含权限列表") 48 | private List privilegeCodes = new ArrayList<>(); 49 | } 50 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/menu/MenuDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.menu; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value = "MenuDTO", description = "菜单信息") 11 | public class MenuDTO implements Serializable { 12 | 13 | @ApiModelProperty("菜单id") 14 | private Long id; 15 | 16 | @ApiModelProperty("菜单父级id") 17 | private Long parentId; 18 | 19 | @ApiModelProperty("菜单标题") 20 | private String title; 21 | 22 | @ApiModelProperty("菜单跳转url") 23 | private String url; 24 | 25 | @ApiModelProperty("页面标识") 26 | private String code; 27 | 28 | @ApiModelProperty("菜单图标") 29 | private String icon; 30 | 31 | @ApiModelProperty("排序") 32 | private Integer sort; 33 | 34 | @ApiModelProperty("说明") 35 | private String comment; 36 | 37 | /** 38 | * 所属应用标识,作为资源的必要属性 39 | */ 40 | @ApiModelProperty("所属应用编码") 41 | private String applicationCode; 42 | 43 | @ApiModelProperty("所属应用") 44 | private String application; 45 | /** 46 | * 绑定的权限标识,作为资源的必要属性 47 | */ 48 | @ApiModelProperty("绑定的权限编码") 49 | private String privilegeCode; 50 | 51 | @ApiModelProperty("状态") 52 | private Integer status; 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/menu/MenuQueryDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.menu; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value = "MenuQueryDTO", description = "菜单查询参数") 11 | public class MenuQueryDTO implements Serializable { 12 | 13 | @ApiModelProperty("所属应用") 14 | private String applicationCode; 15 | 16 | @ApiModelProperty("菜单标题") 17 | private String title; 18 | 19 | @ApiModelProperty("状态") 20 | private Integer status; 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/resource/ApplicationDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.resource; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value = "ApplicationDTO", description = "应用信息") 11 | public class ApplicationDTO implements Serializable { 12 | 13 | 14 | @ApiModelProperty("id") 15 | private Long id; 16 | 17 | @ApiModelProperty("应用名称") 18 | private String name; 19 | 20 | @ApiModelProperty("应用编码,跨租户唯一") 21 | private String code; 22 | 23 | @ApiModelProperty("应用所属租户") 24 | private Long tenantId; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/resource/ApplicationQueryParams.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.resource; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | 5 | 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | 10 | @Data 11 | @ApiModel(value = "ApplicationQueryParams", description = "应用查询参数") 12 | public class ApplicationQueryParams { 13 | 14 | @ApiModelProperty("应用名称(模糊匹配)") 15 | private String name; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/resource/ResourceAPPDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.resource; 2 | 3 | import io.swagger.annotations.ApiModelProperty; 4 | import lombok.Data; 5 | 6 | import java.io.Serializable; 7 | 8 | @Data 9 | public class ResourceAPPDTO implements Serializable { 10 | 11 | //appication.* 12 | @ApiModelProperty("应用名称") 13 | private String name; 14 | 15 | @ApiModelProperty("应用编码,跨租户唯一") 16 | private String code; 17 | 18 | //////////////////////////////////////////////////////////////////////////////////////// 19 | //resource.* 20 | /** 21 | * 父id 22 | */ 23 | @ApiModelProperty("父id") 24 | private Long parentId; 25 | 26 | /** 27 | * 菜单标题 28 | */ 29 | @ApiModelProperty("菜单标题") 30 | private String title; 31 | 32 | /** 33 | * 链接url 34 | */ 35 | @ApiModelProperty("链接url") 36 | private String url; 37 | 38 | /** 39 | * 图标 40 | */ 41 | @ApiModelProperty("图标") 42 | private String icon; 43 | 44 | /** 45 | * 排序 46 | */ 47 | @ApiModelProperty("排序") 48 | private Integer sort; 49 | 50 | /** 51 | * 说明 52 | */ 53 | @ApiModelProperty("说明") 54 | private String comment; 55 | 56 | /** 57 | * 状态 58 | */ 59 | @ApiModelProperty("状态") 60 | private Integer status; 61 | 62 | /** 63 | * 所属应用编码 64 | */ 65 | @ApiModelProperty("所属应用编码") 66 | private String applicationCode; 67 | 68 | /** 69 | * 绑定权限 70 | */ 71 | @ApiModelProperty("绑定权限") 72 | private String privilegeCode; 73 | } 74 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/resource/ResourceDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.resource; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | 11 | /** 12 | * 系统资源 13 | */ 14 | @ApiModel(value = "ResourceDTO", description = "应用资源") 15 | @Data 16 | public class ResourceDTO implements Serializable { 17 | 18 | @ApiModelProperty("应用编码") 19 | String applicationCode; 20 | 21 | 22 | @ApiModelProperty("应用名称") 23 | String applicationName; 24 | 25 | @ApiModelProperty("应用包含资源,按资源类型分包括菜单等资源信息 如 menu:JSONObject") 26 | Map appRes = new HashMap<>(); //按资源类型分包括菜单等资源信息 如 menu:JSONObject 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/AbilityDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "AbilityDTO", description = "套餐包含功能描述,JSON格式的角色与权限") 10 | @Data 11 | public class AbilityDTO implements Serializable { 12 | 13 | @ApiModelProperty("角色名称") 14 | private String roleName; 15 | 16 | @ApiModelProperty("角色编码") 17 | private String roleCode; 18 | 19 | @ApiModelProperty("权限(数组)") 20 | private String[] privileges; 21 | 22 | } 23 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/AccountDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "AccountDTO", description = "账号信息") 10 | @Data 11 | public class AccountDTO implements Serializable { 12 | 13 | @ApiModelProperty("账号id") 14 | private Long id; 15 | 16 | @ApiModelProperty("用户名") 17 | private String username; 18 | 19 | @ApiModelProperty("手机号") 20 | private String mobile; 21 | 22 | @ApiModelProperty("密码") 23 | private String password; 24 | 25 | @ApiModelProperty("盐") 26 | private String salt; 27 | } 28 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/AccountQueryDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "AccountQueryDTO", description = "账号查询条件") 10 | @Data 11 | public class AccountQueryDTO implements Serializable { 12 | 13 | @ApiModelProperty("用户名") 14 | private String username; 15 | 16 | @ApiModelProperty("手机号") 17 | private String mobile; 18 | 19 | @ApiModelProperty("所属租户") 20 | private Long tenantId; 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/AccountRoleDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | @ApiModel(value = "AccountDTO", description = "账号信息") 8 | @Data 9 | public class AccountRoleDTO { 10 | 11 | @ApiModelProperty("账号名称") 12 | private String username; 13 | @ApiModelProperty("角色编码") 14 | private String roleCode; 15 | @ApiModelProperty("租户id") 16 | private Long tenantId; 17 | } 18 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/AccountRoleQueryDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "AccountRoleQueryDTO", description = "管理员信息") 10 | @Data 11 | public class AccountRoleQueryDTO implements Serializable { 12 | 13 | @ApiModelProperty("id") 14 | private Long id; 15 | @ApiModelProperty("账号名称") 16 | private String username; 17 | @ApiModelProperty("角色名称") 18 | private String roleName; 19 | @ApiModelProperty("租户id") 20 | private Long tenantId; 21 | } 22 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/AuthenticationInfo.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "AuthenticationInfo", description = "认证请求信息") 10 | @Data 11 | public class AuthenticationInfo implements Serializable { 12 | 13 | @ApiModelProperty("认证主体:如用户名,手机号等") 14 | private String principal; 15 | 16 | @ApiModelProperty("凭证:如密码,短信认证码等") 17 | private String certificate; 18 | 19 | @ApiModelProperty("认证类型:短信快捷认证、用户名密码认证、二维码认证等") 20 | private String authenticationType; 21 | 22 | @ApiModelProperty("短信认证时需要传key到短信微服务校验,格式:sms:3d21042d054548b08477142bbca95cfa") 23 | private String smsKey; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/BundleDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "BundleDTO", description = "套餐信息") 10 | @Data 11 | public class BundleDTO implements Serializable { 12 | 13 | @ApiModelProperty("主键,套餐id") 14 | private Long id; 15 | 16 | @ApiModelProperty("套餐名称") 17 | private String name; 18 | 19 | @ApiModelProperty("套餐编码") 20 | private String code; 21 | 22 | @ApiModelProperty("租户类型编码") 23 | private String tenantTypeCode; 24 | 25 | @ApiModelProperty("套餐包含功能描述,JSON格式的角色与权限") 26 | private String ability; 27 | 28 | @ApiModelProperty("API调用次数/月") 29 | private Integer numberOfInvocation; 30 | 31 | @ApiModelProperty("并发数/秒") 32 | private Integer numberOfConcurrent; 33 | 34 | @ApiModelProperty("允许创建应用数量") 35 | private Integer numberOfApp; 36 | 37 | @ApiModelProperty("套餐说明") 38 | private String comment; 39 | 40 | @ApiModelProperty("是否为初始化套餐,1表示是初始化套餐,0表示不是") 41 | private Boolean initialize; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/ChangeAccountPwdDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @Data 10 | @ApiModel(value = "ChangeAccountPwdDTO", description = "重置账号密码") 11 | public class ChangeAccountPwdDTO implements Serializable { 12 | 13 | @ApiModelProperty("账号Id") 14 | private Long accountId; 15 | 16 | @ApiModelProperty("账号名") 17 | private String userName; 18 | 19 | 20 | @ApiModelProperty("密码") 21 | private String password; 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/CreateAccountRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "CreateAccountRequestDTO", description = "创建账号请求") 10 | @Data 11 | public class CreateAccountRequestDTO implements Serializable { 12 | 13 | @ApiModelProperty("用户名") 14 | private String username; 15 | 16 | @ApiModelProperty("手机号") 17 | private String mobile; 18 | 19 | @ApiModelProperty("密码") 20 | private String password; 21 | 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/CreateTenantRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "CreateTenantRequestDTO", description = "创建租户请求信息") 10 | @Data 11 | public class CreateTenantRequestDTO implements Serializable { 12 | 13 | @ApiModelProperty("租户名称") 14 | private String name; 15 | 16 | @ApiModelProperty("租户类型编码") 17 | private String tenantTypeCode; 18 | 19 | @ApiModelProperty("初始化套餐编码,用于初始化套餐 ABILITY,若为空则使用该租户类型的初始化套餐") 20 | private String bundleCode; 21 | 22 | @ApiModelProperty("租户管理员登录手机号") 23 | private String mobile; 24 | 25 | @ApiModelProperty("租户管理员登录密码") 26 | private String password; 27 | 28 | @ApiModelProperty("租户管理员登录用户名") 29 | private String username; 30 | 31 | 32 | } 33 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/LoginInfoDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import com.shanjupay.user.api.dto.authorization.AuthorizationInfoDTO; 4 | import com.shanjupay.user.api.dto.resource.ResourceDTO; 5 | import io.swagger.annotations.ApiModel; 6 | import io.swagger.annotations.ApiModelProperty; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | import java.util.HashMap; 11 | import java.util.List; 12 | import java.util.Map; 13 | 14 | @ApiModel(value = "LoginInfoDTO", description = "登录响应信息") 15 | @Data 16 | public class LoginInfoDTO implements Serializable { 17 | 18 | @ApiModelProperty("账号id") 19 | private Long id; 20 | 21 | @ApiModelProperty("用户名") 22 | private String username; 23 | 24 | @ApiModelProperty("手机号") 25 | private String mobile; 26 | 27 | @ApiModelProperty("账号所属多个租户") 28 | private List tenants; 29 | 30 | @ApiModelProperty("账号所属多个租户下的权限") 31 | private Map tenantAuthorizationInfoMap = new HashMap<>(); 32 | 33 | @ApiModelProperty("账号所属多个租户下,不同应用的资源,如:{租户A:[{应用1权限信息},{应用2权限信息}],租户B:[{},{}...]}") 34 | Map> resources = new HashMap<>(); 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/LoginRequestDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "LoginRequestDTO", description = "登录请求信息") 10 | @Data 11 | public class LoginRequestDTO implements Serializable { 12 | 13 | /** 14 | * 认证主体:如用户名,手机号等 15 | */ 16 | @ApiModelProperty("认证主体:如用户名,手机号等") 17 | private String principal; 18 | 19 | /** 20 | * 凭证:如密码,短信认证码等 21 | */ 22 | @ApiModelProperty("凭证:如密码,短信认证码等") 23 | private String certificate; 24 | 25 | 26 | /** 27 | * 认证类型:短信快捷认证 type_message、用户名密码认证 type_user、二维码认证等 28 | */ 29 | @ApiModelProperty("认证类型:短信快捷认证、用户名密码认证、二维码认证等") 30 | private String authenticationType; 31 | 32 | /** 33 | * 短信认证时需要传key到短信微服务校验,格式:sms:3d21042d054548b08477142bbca95cfa 34 | */ 35 | @ApiModelProperty("短信认证时需要传key") 36 | private String smsKey; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/TenRolePrivilegeDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "TenRolePrivilegeDTO", description = "租户角色权限信息") 10 | @Data 11 | public class TenRolePrivilegeDTO implements Serializable { 12 | 13 | @ApiModelProperty("租户id") 14 | private Long tenantId; 15 | 16 | @ApiModelProperty("角色编码") 17 | private String roleCode; 18 | 19 | @ApiModelProperty("权限编码") 20 | private String privilegeCode; 21 | } 22 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/TenantDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "TenantDTO", description = "租户信息") 10 | @Data 11 | public class TenantDTO implements Serializable { 12 | 13 | @ApiModelProperty("租户id") 14 | private Long id; 15 | 16 | @ApiModelProperty("租户名称") 17 | private String name; 18 | 19 | @ApiModelProperty("租户类型编码") 20 | private String tenantTypeCode; 21 | 22 | @ApiModelProperty("套餐编码") 23 | private String bundleCode; 24 | 25 | 26 | } 27 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-api/src/main/java/com/shanjupay/user/api/dto/tenant/TenantQueryDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.api.dto.tenant; 2 | 3 | import io.swagger.annotations.ApiModel; 4 | import io.swagger.annotations.ApiModelProperty; 5 | import lombok.Data; 6 | 7 | import java.io.Serializable; 8 | 9 | @ApiModel(value = "TenantQueryDTO", description = "租户查询条件") 10 | @Data 11 | public class TenantQueryDTO implements Serializable { 12 | 13 | @ApiModelProperty("租户名称") 14 | private String name; 15 | 16 | @ApiModelProperty("租户类型") 17 | private String tenantTypeCode; 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/UserBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.http.client.OkHttp3ClientHttpRequestFactory; 8 | import org.springframework.web.client.RestTemplate; 9 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 10 | 11 | @SpringBootApplication 12 | @EnableDiscoveryClient 13 | @EnableSwagger2 14 | public class UserBootstrap { 15 | 16 | public static void main(String[] args) { 17 | SpringApplication.run(UserBootstrap.class, args); 18 | } 19 | 20 | @Bean 21 | public RestTemplate restTemplate() { 22 | return new RestTemplate(new OkHttp3ClientHttpRequestFactory()); 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/config/MybatisPlusConfig.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.config; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; 4 | import com.baomidou.mybatisplus.extension.plugins.PerformanceInterceptor; 5 | import org.mybatis.spring.annotation.MapperScan; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | 9 | import java.util.Properties; 10 | 11 | /** 12 | *

13 | * Mybatis-Plus 配置 14 | *

15 | */ 16 | @Configuration 17 | @MapperScan("com.shanjupay.**.mapper") 18 | public class MybatisPlusConfig { 19 | 20 | /** 21 | * 分页插件,自动识别数据库类型 22 | */ 23 | @Bean 24 | public PaginationInterceptor paginationInterceptor() { 25 | return new PaginationInterceptor(); 26 | } 27 | 28 | /** 29 | * 启用性能分析插件 30 | */ 31 | @Bean 32 | public PerformanceInterceptor performanceInterceptor(){ 33 | return new PerformanceInterceptor(); 34 | } 35 | } -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/config/SwaggerConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.config; 2 | 3 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import springfox.documentation.builders.ApiInfoBuilder; 7 | import springfox.documentation.builders.PathSelectors; 8 | import springfox.documentation.builders.RequestHandlerSelectors; 9 | import springfox.documentation.service.ApiInfo; 10 | import springfox.documentation.service.Contact; 11 | import springfox.documentation.spi.DocumentationType; 12 | import springfox.documentation.spring.web.plugins.Docket; 13 | import springfox.documentation.swagger2.annotations.EnableSwagger2; 14 | 15 | @Configuration 16 | @ConditionalOnProperty(prefix = "swagger",value = {"enable"},havingValue = "true") 17 | @EnableSwagger2 18 | public class SwaggerConfiguration { 19 | 20 | @Bean 21 | public Docket buildDocket() { 22 | return new Docket(DocumentationType.SWAGGER_2) 23 | .apiInfo(buildApiInfo()) 24 | .select() 25 | // 要扫描的API(Controller)基础包 26 | .apis(RequestHandlerSelectors.basePackage("com.shanjupay.user.controller")) 27 | .paths(PathSelectors.any()) 28 | .build(); 29 | } 30 | 31 | /** 32 | * @param 33 | * @return springfox.documentation.service.ApiInfo 34 | * @Title: 构建API基本信息 35 | * @methodName: buildApiInfo 36 | */ 37 | private ApiInfo buildApiInfo() { 38 | Contact contact = new Contact("开发者","",""); 39 | return new ApiInfoBuilder() 40 | .title("API文档") 41 | .description("") 42 | .contact(contact) 43 | .version("1.0.0").build(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/AccountConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.tenant.AccountDTO; 4 | import com.shanjupay.user.entity.Account; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | @Mapper 9 | public interface AccountConvert { 10 | 11 | AccountConvert INSTANCE = Mappers.getMapper(AccountConvert.class); 12 | 13 | //@Mappings({ 14 | // @Mapping(target="username", source="username") 15 | //}) 16 | AccountDTO entity2dto(Account entity); 17 | 18 | 19 | //@Mappings({ 20 | // @Mapping(target="username", source="username"), 21 | // @Mapping(target = "mobile",source="mobile"), 22 | // @Mapping(target = "password",source="password"), 23 | // @Mapping(target = "salt",source="salt") 24 | //}) 25 | Account dto2entity(AccountDTO dto); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/AuthorizationPrivilegeConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.authorization.PrivilegeDTO; 4 | import com.shanjupay.user.entity.AuthorizationPrivilege; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface AuthorizationPrivilegeConvert { 12 | AuthorizationPrivilegeConvert INSTANCE = Mappers.getMapper(AuthorizationPrivilegeConvert.class); 13 | 14 | PrivilegeDTO entity2dto(AuthorizationPrivilege entity); 15 | 16 | AuthorizationPrivilege dto2entity(PrivilegeDTO dto); 17 | 18 | List entitylist2dto(List authorizationRole); 19 | } 20 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/AuthorizationRoleConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.authorization.RoleDTO; 4 | import com.shanjupay.user.entity.AuthorizationRole; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.Mapping; 7 | import org.mapstruct.Mappings; 8 | import org.mapstruct.factory.Mappers; 9 | 10 | import java.util.List; 11 | 12 | @Mapper 13 | public interface AuthorizationRoleConvert { 14 | 15 | AuthorizationRoleConvert INSTANCE = Mappers.getMapper(AuthorizationRoleConvert.class); 16 | 17 | @Mappings({ 18 | @Mapping(target="name",source = "name"), 19 | @Mapping(target="code",source = "code"), 20 | @Mapping(target="tenantId",source = "tenantId")} 21 | ) 22 | RoleDTO entity2dto(AuthorizationRole entity); 23 | 24 | @Mappings({ 25 | @Mapping(target="name",source = "name"), 26 | @Mapping(target="code",source = "code"), 27 | @Mapping(target="tenantId",source = "tenantId")} 28 | ) 29 | AuthorizationRole dto2entity(RoleDTO dto); 30 | 31 | List entitylist2dto(List authorizationRole); 32 | 33 | List dtolist2entity(List roleDTOS); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/BundleConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.tenant.BundleDTO; 4 | import com.shanjupay.user.entity.Bundle; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface BundleConvert { 12 | 13 | BundleConvert INSTANCE = Mappers.getMapper(BundleConvert.class); 14 | 15 | BundleDTO entity2dto(Bundle entity); 16 | 17 | Bundle dto2entity(BundleDTO dto); 18 | 19 | List entitylist2dto(List bundle); 20 | } 21 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/ResourceApplicationConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.resource.ApplicationDTO; 4 | import com.shanjupay.user.entity.ResourceApplication; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface ResourceApplicationConvert { 12 | 13 | 14 | ResourceApplicationConvert INSTANCE = Mappers.getMapper(ResourceApplicationConvert.class); 15 | 16 | ApplicationDTO entity2dto(ResourceApplication entity); 17 | 18 | ResourceApplication dto2entity(ApplicationDTO dto); 19 | 20 | List entitylist2dto(List bundle); 21 | } 22 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/ResourceMenuConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.menu.MenuDTO; 4 | import com.shanjupay.user.entity.ResourceMenu; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | public interface ResourceMenuConvert { 12 | 13 | ResourceMenuConvert INSTANCE = Mappers.getMapper(ResourceMenuConvert.class); 14 | 15 | MenuDTO entity2dto(ResourceMenu entity); 16 | 17 | ResourceMenu dto2entity(MenuDTO dto); 18 | 19 | List entitylist2dto(List resourceMenu); 20 | 21 | List dtolist2entity(List menuDTO); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/TenantConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.tenant.TenantDTO; 4 | import com.shanjupay.user.entity.Tenant; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | @Mapper 9 | public interface TenantConvert { 10 | 11 | TenantConvert INSTANCE = Mappers.getMapper(TenantConvert.class); 12 | 13 | TenantDTO entity2dto(Tenant entity); 14 | 15 | Tenant dto2entity(TenantDTO dto); 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/convert/TenantRequestConvert.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.convert; 2 | 3 | import com.shanjupay.user.api.dto.tenant.CreateTenantRequestDTO; 4 | import com.shanjupay.user.entity.Tenant; 5 | import org.mapstruct.Mapper; 6 | import org.mapstruct.factory.Mappers; 7 | 8 | @Mapper 9 | public interface TenantRequestConvert { 10 | 11 | TenantRequestConvert INSTANCE = Mappers.getMapper(TenantRequestConvert.class); 12 | 13 | CreateTenantRequestDTO entity2dto(Tenant entity); 14 | 15 | Tenant dto2entity(CreateTenantRequestDTO dto); 16 | } 17 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/Account.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | 12 | @Data 13 | @TableName("account") 14 | public class Account implements Serializable { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | /** 19 | * 主键 20 | */ 21 | @TableId(value="ID",type = IdType.AUTO) 22 | private Long id; 23 | 24 | /** 25 | * 用户名 26 | */ 27 | @TableField("USERNAME") 28 | private String username; 29 | 30 | /** 31 | * 手机号 32 | */ 33 | @TableField("MOBILE") 34 | private String mobile; 35 | 36 | /** 37 | * 密码 38 | */ 39 | @TableField("PASSWORD") 40 | private String password; 41 | 42 | /** 43 | * 盐 44 | */ 45 | @TableField("SALT") 46 | private String salt; 47 | 48 | 49 | } 50 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/AccountRole.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 账号-角色关系 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("account_role") 21 | public class AccountRole implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | // @TableId("ID") 29 | // @GeneratedValue(strategy = GenerationType.IDENTITY) 30 | @TableId(value="ID",type = IdType.AUTO) 31 | private Long id; 32 | 33 | /** 34 | * 用户名 35 | */ 36 | @TableField("USERNAME") 37 | private String username; 38 | 39 | /** 40 | * 角色编码 41 | */ 42 | @TableField("ROLE_CODE") 43 | private String roleCode; 44 | 45 | /** 46 | * 租户id 47 | */ 48 | @TableField("TENANT_ID") 49 | private Long tenantId; 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/AuthorizationPrivilege.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 权限 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("authorization_privilege") 21 | public class AuthorizationPrivilege implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 权限名称 33 | */ 34 | @TableField("NAME") 35 | private String name; 36 | 37 | /** 38 | * 权限编码 39 | */ 40 | @TableField("CODE") 41 | private String code; 42 | 43 | /** 44 | * 所属权限组id 45 | */ 46 | @TableField("PRIVILEGE_GROUP_ID") 47 | private Long privilegeGroupId; 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/AuthorizationPrivilegeGroup.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 权限组 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("authorization_privilege_group") 21 | public class AuthorizationPrivilegeGroup implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 父id 33 | */ 34 | @TableField("PARENT_ID") 35 | private Long parentId; 36 | 37 | /** 38 | * 权限组名称 39 | */ 40 | @TableField("NAME") 41 | private String name; 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/AuthorizationRole.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 角色信息 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("authorization_role") 21 | public class AuthorizationRole implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | //@TableId("ID") 29 | //@GeneratedValue(strategy = GenerationType.IDENTITY) 30 | @TableId(value="ID",type = IdType.AUTO) 31 | private Long id; 32 | 33 | /** 34 | * 角色名称 35 | */ 36 | @TableField("NAME") 37 | private String name; 38 | 39 | /** 40 | * 角色编码 41 | */ 42 | @TableField("CODE") 43 | private String code; 44 | 45 | /** 46 | * 租户id 47 | */ 48 | @TableField("TENANT_ID") 49 | private Long tenantId; 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/AuthorizationRolePrivilege.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 角色-权限关系 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("authorization_role_privilege") 21 | public class AuthorizationRolePrivilege implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | //@TableId("ID") 29 | //@GeneratedValue(strategy = GenerationType.IDENTITY) 30 | @TableId(value="ID",type = IdType.AUTO) 31 | private Long id; 32 | 33 | /** 34 | * 角色id 35 | */ 36 | @TableField("ROLE_ID") 37 | private Long roleId; 38 | 39 | /** 40 | * 权限id 41 | */ 42 | @TableField("PRIVILEGE_ID") 43 | private Long privilegeId; 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/ResourceApplication.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 应用信息 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("resource_application") 21 | public class ResourceApplication implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 应用名称 33 | */ 34 | @TableField("NAME") 35 | private String name; 36 | 37 | /** 38 | * 应用编码 39 | */ 40 | @TableField("CODE") 41 | private String code; 42 | 43 | /** 44 | * 租户id 45 | */ 46 | @TableField("TENANT_ID") 47 | private Long tenantId; 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/ResourceButton.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 菜单 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("resource_button") 21 | public class ResourceButton implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 父id 33 | */ 34 | @TableField("PARENT_ID") 35 | private Long parentId; 36 | 37 | /** 38 | * 按钮标题 39 | */ 40 | @TableField("TITLE") 41 | private String title; 42 | 43 | /** 44 | * 链接url 45 | */ 46 | @TableField("URL") 47 | private String url; 48 | 49 | /** 50 | * 图标 51 | */ 52 | @TableField("ICON") 53 | private String icon; 54 | 55 | /** 56 | * 排序 57 | */ 58 | @TableField("SORT") 59 | private Integer sort; 60 | 61 | /** 62 | * 说明 63 | */ 64 | @TableField("COMMENT") 65 | private String comment; 66 | 67 | /** 68 | * 状态 69 | */ 70 | @TableField("STATUS") 71 | private Integer status; 72 | 73 | /** 74 | * 所属应用编码 75 | */ 76 | @TableField("APPLICATION_CODE") 77 | private String applicationCode; 78 | 79 | /** 80 | * 绑定权限 81 | */ 82 | @TableField("PRIVILEGE_CODE") 83 | private String privilegeCode; 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/ResourceMenu.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 菜单 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Data 20 | @TableName("resource_menu") 21 | public class ResourceMenu implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 父id 33 | */ 34 | @TableField("PARENT_ID") 35 | private Long parentId; 36 | 37 | /** 38 | * 菜单标题 39 | */ 40 | @TableField("TITLE") 41 | private String title; 42 | 43 | /** 44 | * 链接url 45 | */ 46 | @TableField("URL") 47 | private String url; 48 | 49 | /** 50 | * 图标 51 | */ 52 | @TableField("ICON") 53 | private String icon; 54 | 55 | /** 56 | * 排序 57 | */ 58 | @TableField("SORT") 59 | private Integer sort; 60 | 61 | /** 62 | * 说明 63 | */ 64 | @TableField("COMMENT") 65 | private String comment; 66 | 67 | /** 68 | * 状态 69 | */ 70 | @TableField("STATUS") 71 | private Integer status; 72 | 73 | /** 74 | * 所属应用编码 75 | */ 76 | @TableField("APPLICATION_CODE") 77 | private String applicationCode; 78 | 79 | /** 80 | * 绑定权限 81 | */ 82 | @TableField("PRIVILEGE_CODE") 83 | private String privilegeCode; 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/Tenant.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 14 | *

15 | * 16 | * 17 | * @since 2019-07-15 18 | */ 19 | @Data 20 | @TableName("tenant") 21 | public class Tenant implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 租户名称 33 | */ 34 | @TableField("NAME") 35 | private String name; 36 | 37 | /** 38 | * 租户类型编码 39 | */ 40 | @TableField("TENANT_TYPE_CODE") 41 | private String tenantTypeCode; 42 | 43 | /** 44 | * 购买套餐编码 45 | */ 46 | @TableField("BUNDLE_CODE") 47 | private String bundleCode; 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/TenantAccount.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 14 | *

15 | * 16 | * 17 | * @since 2019-07-15 18 | */ 19 | @Data 20 | @TableName("tenant_account") 21 | public class TenantAccount implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | @TableId(value="ID",type = IdType.AUTO) 26 | private Long id; 27 | 28 | /** 29 | * 租户id 30 | */ 31 | @TableField("TENANT_ID") 32 | private Long tenantId; 33 | 34 | /** 35 | * 账号d 36 | */ 37 | @TableField("ACCOUNT_ID") 38 | private Long accountId; 39 | 40 | /** 41 | * 是否是租户管理员 42 | */ 43 | @TableField("IS_ADMIN") 44 | private Boolean isAdmin; 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/entity/TenantType.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.entity; 2 | 3 | import com.baomidou.mybatisplus.annotation.IdType; 4 | import com.baomidou.mybatisplus.annotation.TableField; 5 | import com.baomidou.mybatisplus.annotation.TableId; 6 | import com.baomidou.mybatisplus.annotation.TableName; 7 | import lombok.Data; 8 | 9 | import java.io.Serializable; 10 | 11 | /** 12 | *

13 | * 14 | *

15 | * 16 | * 17 | * @since 2019-07-15 18 | */ 19 | @Data 20 | @TableName("tenant_type") 21 | public class TenantType implements Serializable { 22 | 23 | private static final long serialVersionUID = 1L; 24 | 25 | /** 26 | * 主键 27 | */ 28 | @TableId(value="ID",type = IdType.AUTO) 29 | private Long id; 30 | 31 | /** 32 | * 租户类型名称 33 | */ 34 | @TableField("NAME") 35 | private String name; 36 | 37 | /** 38 | * 租户类型编码 39 | */ 40 | @TableField("CODE") 41 | private String code; 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/AccountMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/AuthorizationPrivilegeGroupMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.shanjupay.user.api.dto.authorization.PrivilegeTreeDTO; 4 | import com.shanjupay.user.entity.AuthorizationPrivilegeGroup; 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 6 | import org.apache.ibatis.annotations.Select; 7 | import org.springframework.stereotype.Repository; 8 | 9 | import java.util.List; 10 | 11 | /** 12 | *

13 | * 权限组 Mapper 接口 14 | *

15 | * 16 | * 17 | * @since 2019-08-13 18 | */ 19 | @Repository 20 | public interface AuthorizationPrivilegeGroupMapper extends BaseMapper { 21 | 22 | @Select("select * from authorization_privilege_group") 23 | List selectPrivilegeGroup(); 24 | } 25 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/AuthorizationRolePrivilegeMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.shanjupay.user.entity.AuthorizationRolePrivilege; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Options; 7 | import org.apache.ibatis.annotations.Param; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | /** 13 | *

14 | * 角色-权限关系 Mapper 接口 15 | *

16 | * 17 | * 18 | * @since 2019-08-13 19 | */ 20 | @Repository 21 | public interface AuthorizationRolePrivilegeMapper extends BaseMapper { 22 | 23 | @Insert("") 27 | //@Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "ID") 28 | void insertRolePrivilege(@Param("rid") Long rid,@Param("pids") List pids); 29 | } 30 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/BundleMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.shanjupay.user.entity.Bundle; 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 5 | import org.apache.ibatis.annotations.Param; 6 | import org.apache.ibatis.annotations.Select; 7 | import org.springframework.stereotype.Repository; 8 | 9 | /** 10 | *

11 | * Mapper 接口 12 | *

13 | * 14 | * 15 | * @since 2019-08-13 16 | */ 17 | @Repository 18 | public interface BundleMapper extends BaseMapper { 19 | 20 | //@Select("select * from bundle where CODE=#{bundleCode}") 21 | //Bundle selectBundleByCode(@Param("bundleCode") String bundleCode); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/ResourceApplicationMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 4 | import com.shanjupay.user.api.dto.resource.ApplicationDTO; 5 | import com.shanjupay.user.api.dto.resource.ApplicationQueryParams; 6 | import com.shanjupay.user.entity.ResourceApplication; 7 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 8 | import org.apache.ibatis.annotations.Param; 9 | import org.apache.ibatis.annotations.Select; 10 | import org.springframework.stereotype.Repository; 11 | 12 | import java.util.List; 13 | 14 | /** 15 | *

16 | * 应用信息 Mapper 接口 17 | *

18 | * 19 | * 20 | * @since 2019-08-13 21 | */ 22 | @Repository 23 | public interface ResourceApplicationMapper extends BaseMapper { 24 | 25 | @Select("") 33 | List selectAppByPage(@Param("page") Page page, @Param("query") ApplicationQueryParams query); 34 | } 35 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/ResourceButtonMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.user.api.dto.resource.ResourceDTO; 5 | import com.shanjupay.user.entity.ResourceButton; 6 | import org.apache.ibatis.annotations.Param; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | 13 | /** 14 | *

15 | * 菜单 Mapper 接口 16 | *

17 | * 18 | * 19 | * @since 2019-08-13 20 | */ 21 | @Repository 22 | public interface ResourceButtonMapper extends BaseMapper { 23 | 24 | /* @Select("") 30 | List selectButtonByPrivilegeInApp(@Param("privilegeCodes") List privilegeCodes, @Param("applicationCode") String applicationCode); 31 | */ 32 | } 33 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/TenantAccountMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.user.api.dto.tenant.AccountRoleQueryDTO; 5 | import com.shanjupay.user.entity.TenantAccount; 6 | import org.apache.ibatis.annotations.Delete; 7 | import org.apache.ibatis.annotations.Param; 8 | import org.apache.ibatis.annotations.Select; 9 | import org.springframework.stereotype.Repository; 10 | 11 | /** 12 | *

13 | * Mapper 接口 14 | *

15 | * 16 | * 17 | * @since 2019-07-15 18 | */ 19 | @Repository 20 | public interface TenantAccountMapper extends BaseMapper { 21 | 22 | @Select("select count(*) from tenant_account where ACCOUNT_ID IN(select id from account where USERNAME=#{username})") 23 | int selectTenantByUsernameInAccount(@Param("username") String username); 24 | 25 | @Delete("delete from tenant_account where TENANT_ID=#{tenantId} and ACCOUNT_ID=#{accountId} ") 26 | void deleteAccountInTenant(@Param("tenantId") Long tenantId,@Param("accountId") Long accountId); 27 | 28 | @Select("select ar.USERNAME as username,r.`NAME` as roleName,r.TENANT_ID as tenantId,ar.ID as id " + 29 | "from account_role ar " + 30 | "join authorization_role r on ar.ROLE_CODE=r.`CODE` " + 31 | "and ar.TENANT_ID=r.TENANT_ID " + 32 | "where r.TENANT_ID=#{tenantId} " + 33 | "and r.`CODE`=#{roleCode} " + 34 | "and ar.USERNAME=#{username}") 35 | AccountRoleQueryDTO selectAccountRole(@Param("username") String username,@Param("roleCode") String roleCode,@Param("tenantId") Long tenantId); 36 | } 37 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/TenantAccountMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/TenantMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/TenantTypeMapper.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import com.shanjupay.user.entity.TenantType; 5 | import org.springframework.stereotype.Repository; 6 | 7 | /** 8 | *

9 | * Mapper 接口 10 | *

11 | * 12 | * 13 | * @since 2019-07-15 14 | */ 15 | @Repository 16 | public interface TenantTypeMapper extends BaseMapper { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/java/com/shanjupay/user/mapper/TenantTypeMapper.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/resources/bootstrap.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 56030 #启动端口 命令行注入 3 | 4 | nacos: 5 | server: 6 | addr: 127.0.0.1:8848 7 | 8 | spring: 9 | application: 10 | name: user-service 11 | main: 12 | allow-bean-definition-overriding: true # Spring Boot 2.1 需要设定 13 | cloud: 14 | nacos: 15 | discovery: 16 | server-addr: ${nacos.server.addr} 17 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 18 | cluster-name: DEFAULT 19 | config: 20 | server-addr: ${nacos.server.addr} # 配置中心地址 21 | file-extension: yaml 22 | namespace: 22405b94-7719-46ec-a487-061b400d77e3 # 默认开发环境 23 | group: SHANJUPAY_GROUP # 聚合支付业务组 24 | ext-config: 25 | - 26 | refresh: true 27 | data-id: spring-boot-http.yaml # spring boot http配置 28 | group: COMMON_GROUP # 通用配置组 29 | - 30 | refresh: true 31 | data-id: spring-boot-starter-druid.yaml # spring boot starter druid配置 32 | group: COMMON_GROUP # 通用配置组 33 | - 34 | refresh: true 35 | data-id: spring-boot-mybatis-plus.yaml # spring boot mybatisplus配置 36 | group: COMMON_GROUP # 通用配置组 37 | 38 | dubbo: 39 | scan: 40 | # dubbo 服务扫描基准包 41 | base-packages: com.shanjupay 42 | protocol: 43 | # dubbo 协议 44 | name: dubbo 45 | port: 20880 46 | registry: 47 | address: nacos://127.0.0.1:8848 48 | application: 49 | qos: 50 | port: 22230 # dubbo qos端口配置 命令行注入 51 | consumer: 52 | check: false 53 | timeout: 3000 54 | retries: -1 55 | 56 | logging: 57 | config: classpath:log4j2.xml 58 | 59 | -------------------------------------------------------------------------------- /shanjupay-user/shanjupay-user-service/src/main/test/com/shanjupay/user/TenRolePrivilegeDTO.java: -------------------------------------------------------------------------------- 1 | package com.shanjupay.user; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class TenRolePrivilegeDTO implements Serializable { 9 | 10 | private Long tenantId; 11 | private String roleCode; 12 | private String privilegeCode; 13 | } 14 | --------------------------------------------------------------------------------