add workflow 泰克客户,dev

This commit is contained in:
root 2024-05-13 13:58:24 +08:00
parent ecc7f5a464
commit faf15590fd
1 changed files with 25 additions and 15 deletions

View File

@ -4,11 +4,11 @@
/*Brilliance stems from wisdoms. */ /*Brilliance stems from wisdoms. */
/*************Head Section**************************************************************************/ /*************Head Section**************************************************************************/
/*Script Use: Periodically load data to :cust_contact_info(客户联系信息) */ /*Script Use: Periodically load data to :cust_contact_info(客户联系信息) */
/*Create Date:2024-05-06 17:07:02 */ /*Create Date:2024-05-13 13:57:59 */
/*SDM Developed By: dev */ /*SDM Developed By: dev */
/*SDM Developed Date: 2024-01-19 */ /*SDM Developed Date: 2024-01-19 */
/*SDM Checked By: dev */ /*SDM Checked By: dev */
/*SDM Checked Date: 2024-05-06 */ /*SDM Checked Date: 2024-05-13 */
/*Script Developed By: dev */ /*Script Developed By: dev */
/*Script Checked By: dev */ /*Script Checked By: dev */
/*Source table 1: :PDMDB.t01_crm_account */ /*Source table 1: :PDMDB.t01_crm_account */
@ -104,7 +104,7 @@ SELECT
,p1.account /*account*/ ,p1.account /*account*/
,coalesce(p3.country_en_name,p4.country_en_name,p1.country) /*country*/ ,coalesce(p3.country_en_name,p4.country_en_name,p1.country) /*country*/
,p1.prov_name /*prov_name*/ ,p1.prov_name /*prov_name*/
,coalesce(p2.area_cn,p1.city_name) /*city_name*/ ,coalesce(p2.city_name,p1.city_name) /*city_name*/
,p1.industry /*industry*/ ,p1.industry /*industry*/
,p1.crm_contact /*crm_contact*/ ,p1.crm_contact /*crm_contact*/
,p1.crm_full_name /*crm_full_name*/ ,p1.crm_full_name /*crm_full_name*/
@ -112,12 +112,12 @@ SELECT
,p1.crm_email /*crm_email*/ ,p1.crm_email /*crm_email*/
,p1.crm_company /*crm_company*/ ,p1.crm_company /*crm_company*/
,p1.crm_account /*crm_account*/ ,p1.crm_account /*crm_account*/
,coalesce(p6.account_name,'') /*account_name*/ ,coalesce(p6.name,'') /*account_name*/
,p1.crm_country_name /*crm_country_name*/ ,p1.crm_country_name /*crm_country_name*/
,p1.crm_prov_name /*crm_prov_name*/ ,p1.crm_prov_name /*crm_prov_name*/
,p1.crm_city_name /*crm_city_name*/ ,p1.crm_city_name /*crm_city_name*/
,1.crm_industry /*crm_industry*/ ,p1.crm_industry /*crm_industry*/
,1.scrm_contact /*scrm_contact*/ ,p1.scrm_contact /*scrm_contact*/
,p1.scrm_full_name /*scrm_full_name*/ ,p1.scrm_full_name /*scrm_full_name*/
,p1.scrm_mobile /*scrm_mobile*/ ,p1.scrm_mobile /*scrm_mobile*/
,p1.scrm_email /*scrm_email*/ ,p1.scrm_email /*scrm_email*/
@ -148,20 +148,20 @@ SELECT
FROM (select FROM (select
p1.contact_id p1.contact_id
,p1.user_id as contact ,p1.user_id as contact
,trim(case when crm_contact <> '' then 'CRM ' else '' end || case when scrm_contact <> '' then 'SCRM ' else '' end ||case when livechat_contact <> '' then 'Livechat ' else '' end) contact_channel ,case when crm_contact ='' and scrm_contact ='' and livechat_contact ='' then 'Udesk' else trim(case when crm_contact <> '' then 'CRM ' else '' end || case when scrm_contact <> '' then 'SCRM ' else '' end ||case when livechat_contact <> '' then 'Livechat ' else '' end) end contact_channel
,coalesce(p2.full_name,p3.full_name,p4.full_name,'') full_name ,coalesce(p2.full_name,p3.full_name,p4.full_name,p5.full_name ,'') full_name
,coalesce(p2.mobile_phone,p3.mobile_phone,p4.mobile_phone,'') mobile ,coalesce(p2.mobile_phone,p3.mobile_phone,p4.mobile_phone,p5.mobile_phone ,'') mobile
,coalesce(p2.email,p3.email,p4.email,'') email ,coalesce(p2.email,p3.email,p4.email,'') email
,coalesce(p3.wechat_id,'') wechat ,coalesce(p3.wechat_id,'') wechat
,coalesce(p2.company_name,p3.company_name,p4.company_name,'') company ,coalesce(p2.company_name,p3.company_name,p4.company_name,p5.company_name ,'') company
,coalesce(p2.account_name,'') account ,coalesce(p2.account_name,'') account
,case when p2.country_name is not null then p2.country_name ,case when p2.country_name is not null then p2.country_name
when p3.wechat_id is not null then 'China' when p3.wechat_id is not null then 'China'
when p4.visitor_country_code is not null then p4.visitor_country_code when p4.visitor_country_code is not null then p4.visitor_country_code
else '' else ''
end country end country
,coalesce(p2.prov_name,p3.prov_name,'') prov_name ,coalesce(p2.prov_name,p3.prov_name,p5.prov_name ,'') prov_name
,coalesce(p2.city_name,p3.city_name,'') city_name ,coalesce(p2.city_name,p3.city_name,p5.city_name ,'') city_name
,coalesce(p2.industry) industry ,coalesce(p2.industry) industry
,p1.crm_contact ,p1.crm_contact
,coalesce(p2.full_name,'') crm_full_name ,coalesce(p2.full_name,'') crm_full_name
@ -169,10 +169,12 @@ p1.contact_id
,coalesce(p2.email,'') crm_email ,coalesce(p2.email,'') crm_email
,coalesce(p2.company_name,'') crm_company ,coalesce(p2.company_name,'') crm_company
,coalesce(p2.account_name,'') crm_account ,coalesce(p2.account_name,'') crm_account
,coalesce(p2.account_name,'') account_name
,coalesce(p2.country_name,'') crm_country_name ,coalesce(p2.country_name,'') crm_country_name
,coalesce(p2.prov_name,'') crm_prov_name ,coalesce(p2.prov_name,'') crm_prov_name
,coalesce(p2.city_name,'') crm_city_name ,coalesce(p2.city_name,'') crm_city_name
,coalesce(p2.industry) crm_industry ,coalesce(p2.industry) crm_industry
,coalesce(p2.post_cd) crm_postcode
,p1.scrm_contact ,p1.scrm_contact
,coalesce(p3.full_name,'') scrm_full_name ,coalesce(p3.full_name,'') scrm_full_name
,coalesce(p3.mobile_phone,'') scrm_mobile ,coalesce(p3.mobile_phone,'') scrm_mobile
@ -187,15 +189,23 @@ p1.contact_id
,coalesce(p4.email,'') livechat_email ,coalesce(p4.email,'') livechat_email
,coalesce(p4.company_name,'') livechat_company ,coalesce(p4.company_name,'') livechat_company
,coalesce(p4.visitor_country_code,'') livechat_country ,coalesce(p4.visitor_country_code,'') livechat_country
from p30_common.cust_contact_mapping p1 ,p5.udesk_contact
,coalesce(p5.full_name,'') udesk_full_name
,coalesce(p5.mobile_phone,'') udesk_mobile
,coalesce(p5.company_name,'') udesk_company
,coalesce(p5.prov_name,'') udesk_prov_name
,coalesce(p5.city_name,'') udesk_city_name
from p30_common.v_cust_contact_mapping_all p1
left join p30_common.d_crm_contact p2 left join p30_common.d_crm_contact p2
on p1.crm_contact =p2.crm_contact_account on p1.crm_contact =p2.crm_contact_account
left join p30_common.d_scrm_contact p3 left join p30_common.d_scrm_contact p3
on p1.scrm_contact =p3.scrm_leads_id on p1.scrm_contact =p3.scrm_leads_id
left join p30_common.d_livechat_contact p4 left join p30_common.d_livechat_contact p4
on p1.livechat_contact =livechat_leads_id) p1 on p1.livechat_contact =livechat_leads_id
left join p30_common.d_udesk_contact p5
on p1.udesk_contact =p5.udesk_contact) p1
LEFT JOIN :PDMDB.t00_china_city_info p2 LEFT JOIN :PDMDB.t00_china_city_info p2
ON upper(p2.area_en) = upper(p1.city_name||'shi') ON upper(p2.city_en) = upper(p1.city_name)
LEFT JOIN :PDMDB.t00_country_info p3 LEFT JOIN :PDMDB.t00_country_info p3
ON upper(p1.country)=upper(p3.country_en_name) ON upper(p1.country)=upper(p3.country_en_name)
LEFT JOIN :PDMDB.t00_country_info p4 LEFT JOIN :PDMDB.t00_country_info p4