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

spring:
  application:
    name: order-service
  
  # 数据源配置
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3307}/${DB_NAME:erp_java}?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
    username: ${DB_USER:erp_user}
    password: ${DB_PASSWORD:erp123456}
    hikari:
      minimum-idle: 5
      maximum-pool-size: 20
      idle-timeout: 30000
      pool-name: OrderServiceHikariCP
      max-lifetime: 1800000
      connection-timeout: 30000
      connection-test-query: SELECT 1

  # Redis配置
  redis:
    host: ${REDIS_HOST:localhost}
    port: ${REDIS_PORT:6379}
    password: ${REDIS_PASSWORD:}
    database: 0
    timeout: 3000
    lettuce:
      pool:
        max-active: 8
        max-idle: 8
        min-idle: 2
        max-wait: -1ms

  # MyBatis Plus配置
  mybatis-plus:
    mapper-locations: classpath*:/mapper/**/*.xml
    type-aliases-package: com.erp.order.**.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: deletedAt
        logic-delete-value: now()

# 服务配置
server:
  port: 8083
  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: 20883
  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

# RocketMQ配置
rocketmq:
  name-server: ${ROCKETMQ_NAMESRV_ADDR:localhost:9876}
  consumer:
    group: order-service-consumer
    topic: order-settlement-topic
  producer:
    group: order-service-producer

# 日志配置
logging:
  level:
    root: INFO
    com.erp.order: DEBUG
    com.erp.order.settlement: 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/order-service.log
    max-size: 100MB
    max-history: 30

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

# 结算模块特有配置
settlement:
  # 默认平台佣金率
  default-commission-rate: 0.006
  # 结算周期类型
  period-types:
    - daily
    - weekly
    - monthly
  # 结算状态
  status:
    pending: pending
    calculating: calculating
    settled: settled
    frozen: frozen
