2022-11-24_update.sql 1.14 KB

ALTER table ecw_offer_log add column customer_id bigint DEFAULT NULL COMMENT '客户ID';
ALTER table ecw_customer_follow add column biz_no varchar(200) DEFAULT NULL COMMENT '业务编码';


-- 迁移报价单商务洽谈跟进记录脚本
INSERT INTO `ecw_customer_follow` (
    id,
    customer_id,
    biz_id,
    biz_no,
    follow_type,
    contact_name,
    follow_time,
    follow_method,
    follow_user_id,
    feedback,
    result,
    admin_id,
    creator,
    create_time,
    deleted
) SELECT
      IF
          ( 1 = 1, NULL, 1 ) AS id,
      o.relation_id AS customer_id,
      l.offer_id AS biz_id,
      l.number AS biz_no,
      4,
      cc.`name` AS contact_name,
      l.follow_up_time AS follow_time,
      l.follow_up_method AS follow_method,
      l.follow_up_salesman_id AS follow_user_id,
      l.customer_feedback AS feedback,
      l.processing_results AS result,
      l.creator AS admin_id,
      l.creator AS creator,
      l.create_time AS create_time,
      0
FROM
    ecw_offer_log l
        LEFT JOIN ecw_offer o ON l.offer_id = o.offer_id
        LEFT JOIN ecw_customer_contacts cc ON l.contacts = cc.id
WHERE
        type = 2