-- Translate callback operation logs that were stored with EJ enum values.
UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '洛阳药房回传：WORKFLOW_STEP_COMPLETED', '洛阳药房回传：流程节点完成')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '洛阳药房回传：REVIEW_APPROVED', '洛阳药房回传：审核通过')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '洛阳药房回传：REVIEW_REJECTED', '洛阳药房回传：审核驳回')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '洛阳药房回传：INVENTORY_SHORTAGE', '洛阳药房回传：库存不足')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '洛阳药房回传：ORDER_CREATED', '洛阳药房回传：订单已创建')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：PENDING_REVIEW', '远端状态：待审核')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：READY_FOR_PRODUCTION', '远端状态：待生产')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：IN_PRODUCTION', '远端状态：生产中')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：PACKAGED', '远端状态：已包装')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：SHIPPED', '远端状态：已发货')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：REJECTED', '远端状态：已驳回')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '远端状态：STOCK_SHORTAGE', '远端状态：库存不足')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `admin_name` = REPLACE(`admin_name`, '洛阳药房：admin', '洛阳药房：管理员')
WHERE `action` = 'ej_pharmacy_callback';

UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = REPLACE(`summary`, '操作人：admin', '操作人：管理员')
WHERE `action` = 'ej_pharmacy_callback';

-- Match Gancao's production-flow presentation for existing EJ workflow logs.
UPDATE `zyt_tcm_prescription_order_log`
SET `summary` = CONCAT(
        '洛阳药房回传：订单药房流转制作中 | 流程：',
        SUBSTRING_INDEX(SUBSTRING_INDEX(`summary`, '；节点：', -1), '；', 1),
        ' | 药房：洛阳药房',
        CASE
            WHEN `summary` LIKE '%操作人：管理员%' THEN ' | 操作人：管理员'
            WHEN `summary` LIKE '%操作人：%' THEN CONCAT(' | 操作人：', SUBSTRING_INDEX(SUBSTRING_INDEX(`summary`, '；操作人：', -1), '；', 1))
            ELSE ''
        END
    ),
    `admin_name` = '洛阳药房系统'
WHERE `action` = 'ej_pharmacy_callback'
  AND `summary` LIKE '洛阳药房回传：流程节点完成；节点：%';
