# AfterSale Service Nacos配置
# 命名空间: public
# 分组: DEFAULT_GROUP
# Data ID: aftersale-service-config.yaml

spring:
  application:
    name: aftersale-service

  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:erp_db}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
    username: ${DB_USER:root}
    password: ${DB_PASSWORD:nihao588+}
    hikari:
      minimum-idle: 5
      maximum-pool-size: 20
      idle-timeout: 30000
      pool-name: AfterSaleServiceHikariCP
      max-lifetime: 1800000
      connection-timeout: 30000
      connection-test-query: SELECT 1

  redis:
    host: ${REDIS_HOST:localhost}
    port: ${REDIS_PORT:6379}
    password: ${REDIS_PASSWORD:Y(@r5tGk9$Lp2}
    database: 0
    timeout: 3000
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 2

  mybatis-plus:
    mapper-locations: classpath*:/mapper/**/*.xml
    type-aliases-package: com.erp.aftersale.**.entity
    configuration:
      map-underscore-to-camel-case: true
      cache-enabled: false
      log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
    global-config:
      db-config:
        id-type: auto
        logic-delete-field: deleted
        logic-delete-value: 1
        logic-not-delete-value: 0

server:
  port: 8087
  servlet:
    context-path: /
  tomcat:
    threads:
      max: 200
      min-spare: 10
    accept-count: 100

dubbo:
  registry:
    address: nacos://${NACOS_SERVER_ADDR:localhost:8848}
    group: DEFAULT_GROUP
  protocol:
    name: dubbo
    port: 20887
  consumer:
    check: false
    timeout: 5000

# Seata分布式事务配置
seata:
  enabled: true
  application-id: ${spring.application.name}
  tx-service-group: erp_tx_group
  registry:
    type: nacos
    nacos:
      server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
      group: DEFAULT_GROUP
  config:
    type: nacos
    nacos:
      server-addr: ${NACOS_SERVER_ADDR:localhost:8848}
      group: DEFAULT_GROUP

logging:
  level:
    root: INFO
    com.erp.aftersale: DEBUG
  pattern:
    console: '%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n'
    file: '%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n'
  file:
    name: /app/logs/aftersale-service.log
    max-size: 100MB
    max-history: 30

management:
  endpoints:
    web:
      exposure:
        include: health,info,metrics,prometheus
  endpoint:
    health:
      show-details: when_authorized
  metrics:
    export:
      prometheus:
        enabled: true

# 售后模块特有配置
aftersale:
  short-id-prefix: AS
  auto-approve-refund-threshold: 10000
  allowed-order-statuses:
    - shipped
    - completed
