-- 协助采购 — 邮件发送日志（执行一次；也可由后台首次访问自动建表）

CREATE TABLE IF NOT EXISTS `purchase_email_send_log` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `from_email` varchar(128) NOT NULL DEFAULT '' COMMENT '发件邮箱',
  `to_email` varchar(128) NOT NULL DEFAULT '' COMMENT '收件邮箱',
  `send_time` datetime DEFAULT NULL COMMENT '发送时间',
  `scene` varchar(32) NOT NULL DEFAULT '' COMMENT '场景：pick_issue初选下发 audit_resend确认页重发',
  `ccydh` varchar(64) NOT NULL DEFAULT '' COMMENT '订单号',
  `company_name` varchar(128) NOT NULL DEFAULT '' COMMENT '供应商名称',
  `mail_subject` varchar(255) NOT NULL DEFAULT '' COMMENT '邮件主题',
  `status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '1成功 0失败',
  `fail_reason` varchar(500) NOT NULL DEFAULT '' COMMENT '失败原因',
  `admin_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT '操作人ID',
  `admin_name` varchar(64) NOT NULL DEFAULT '' COMMENT '操作人',
  `scydgy_id` int(11) NOT NULL DEFAULT 0 COMMENT '工序行ID',
  `purchase_order_id` int(10) unsigned NOT NULL DEFAULT 0 COMMENT 'purchase_order.id',
  `createtime` datetime DEFAULT NULL COMMENT '记录创建时间',
  PRIMARY KEY (`id`),
  KEY `idx_send_time` (`send_time`),
  KEY `idx_to_email` (`to_email`),
  KEY `idx_ccydh` (`ccydh`),
  KEY `idx_scene` (`scene`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='协助采购邮件发送日志';
