DROP PROCEDURE IF EXISTS `AddCustomModule`; CREATE PROCEDURE `AddCustomModule`( crmModule VARCHAR(50), modulename VARCHAR(50), erp_brand VARCHAR(50), erp_product VARCHAR(50) ) BEGIN if LEFT(erp_product,2) <>'云星' and erp_brand='金蝶' then set erp_product=''; end if; ##插入模块表 INSERT INTO exchbill_initial(`exch_name`, `crm_module`, `erp_brand`, `erp_product`, `erp_version`, `erp_billname`, `erp_billtype`, `erp_billquery`, `enable`, `sequence`) SELECT modulename, crmModule, '', '', '', '', '', '', 'yes', 30 FROM dual WHERE NOT exists(SELECT 1 FROM exchbill_initial where crm_module = crmModule); SET @exchbill_id=(SELECT id from exchbill_initial where `crm_module` = crmModule); insert into exchmode_initial(erp_brand,erp_product,exchbill_id,exch_name,exch_mode,presence) select erp_brand,erp_product,@exchbill_id,modulename,'two-way',0 from dual where not exists(select 1 from exchmode_initial where erp_brand = erp_brand and erp_product = erp_product and exchbill_id = @exchbill_id and exch_mode = 'two-way'); insert into exchmode_initial(erp_brand,erp_product,exchbill_id,exch_name,exch_mode,presence) select erp_brand,erp_product,@exchbill_id,modulename,'crm-erp',0 from dual where not exists(select 1 from exchmode_initial where erp_brand = erp_brand and erp_product = erp_product and exchbill_id = @exchbill_id and exch_mode = 'crm-erp'); insert into exchmode_initial(erp_brand,erp_product,exchbill_id,exch_name,exch_mode,presence) select erp_brand,erp_product,@exchbill_id,modulename,'erp-crm',0 from dual where not exists(select 1 from exchmode_initial where erp_brand = erp_brand and erp_product = erp_product and exchbill_id = @exchbill_id and exch_mode = 'erp-crm'); END; delimiter;