import { z } from '@hono/zod-openapi';

// 发货请求DTO
export const DeliveryOrderDto = z.object({
  deliveryType: z.coerce.number().int().min(1, '发货方式最小为1').max(4, '发货方式最大为4').openapi({
    description: '发货方式 1物流快递 2同城配送 3用户自提 4虚拟发货',
    example: 1
  }),
  deliveryCompany: z.string().max(100, '快递公司最多100个字符').nullable().optional().openapi({
    description: '快递公司',
    example: '顺丰速运'
  }),
  deliveryNo: z.string().max(100, '快递单号最多100个字符').nullable().optional().openapi({
    description: '快递单号',
    example: 'SF1234567890'
  }),
  deliveryRemark: z.string().max(500, '发货备注最多500个字符').nullable().optional().openapi({
    description: '发货备注',
    example: '已包装好，请注意查收'
  })
});

// 发货响应DTO
export const DeliveryResponseDto = z.object({
  success: z.boolean().openapi({
    description: '发货是否成功',
    example: true
  }),
  message: z.string().openapi({
    description: '发货结果消息',
    example: '发货成功'
  }),
  order: z.object({
    id: z.number().int().positive().openapi({
      description: '订单ID',
      example: 1
    }),
    orderNo: z.string().openapi({
      description: '订单号',
      example: 'ORD20240101123456'
    }),
    state: z.number().int().openapi({
      description: '订单状态',
      example: 1
    }),
    deliveryType: z.number().int().openapi({
      description: '发货方式',
      example: 1
    }),
    deliveryCompany: z.string().nullable().openapi({
      description: '快递公司',
      example: '顺丰速运'
    }),
    deliveryNo: z.string().nullable().openapi({
      description: '快递单号',
      example: 'SF1234567890'
    }),
    deliveryTime: z.coerce.date().nullable().openapi({
      description: '发货时间',
      example: '2024-01-01T12:00:00Z'
    })
  }).optional()
});