客户标签label61-80.sql 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. CREATE OR REPLACE PROCEDURE shanglifeecif.updateIndividualLable_61_80() IS
  2. DECLARE
  3. BEGIN
  4. --65 是否有满期给付保单 Label61 有满期给付保单 如何判断? 0
  5. --select getdutycode from lmdutygetalive where getdutyname in ('满期保险金','满期生存保险金');
  6. UPDATE shanglifeecif.Individual si1 SET si1.label61 = '有满期给付保单' WHERE si1.scustid IN (
  7. SELECT p.customerno FROM policy_information p WHERE p.contno IN (
  8. SELECT contno FROM lcget WHERE getdutycode IN (select getdutycode from lmdutygetalive where getdutyname in ('满期保险金','满期生存保险金'))
  9. )
  10. );
  11. --67 是否有生存金给付的保单 Label63 有生存金给付保单 无 0
  12. --select getdutycode from lmdutygetalive where getdutyname = '生存保险金';
  13. UPDATE shanglifeecif.Individual si1 SET si1.label62 = '有生存金给付的保单' WHERE si1.scustid IN (
  14. SELECT p.customerno FROM policy_information p WHERE p.contno IN (
  15. SELECT contno FROM lcget WHERE getdutycode IN (select getdutycode from lmdutygetalive where getdutyname = '生存保险金')
  16. )
  17. );
  18. --68 是否有红利可领取的保单 Label64 有红利可领取保单 无 0
  19. UPDATE shanglifeecif.Individual si1 SET si1.label64 = '红利可领取的保单' WHERE si1.scustid IN
  20. (SELECT p.customerno FROM policy_information p,lmriskapp l WHERE p.riskcode = l.riskcode AND l.bonusflag = 1);
  21. --69 一单寿险客户 Label65 一单寿险客户 客户仅购买了一张保单,且保单类型为寿险型保单
  22. UPDATE shanglifeecif.Individual si1 SET si1.label65 = '一单寿险客户' WHERE si1.scustid IN (SELECT t.customerno FROM (
  23. SELECT count(*) AS pnum,p.customerno FROM POLICY_INFORMATION p
  24. LEFT JOIN lmriskapp b on p.riskcode = b.riskcode
  25. WHERE b.kindcode = 'L' GROUP BY p.customerno
  26. ) t WHERE t.pnum = 1);
  27. --70 缴费期满客户 Label66 缴费期满客户 POLICY_INFORMATION:paycount= payendyear 客户缴费期数已满
  28. UPDATE shanglifeecif.Individual si1 SET si1.label66 = '缴费期满客户' WHERE si1.scustid IN (SELECT t.customerno FROM (
  29. SELECT count(*) AS pnum,p.customerno FROM POLICY_INFORMATION p
  30. WHERE p.paycount = p.payendyear GROUP BY p.customerno
  31. ) t WHERE t.pnum > 0);
  32. --71 生日与司庆日同一天客户 Label67 生日与司庆日同天 2月15号 为司庆日 客户生日和公司司庆日为同一天
  33. UPDATE shanglifeecif.Individual si1 SET si1.Label67 = '司庆日' where si1.birthday like '%-02-15%';
  34. --72 持有有效保单产品类型客户标签 Label68 持有有效保单,未持有有效保单 客户名下是否有投保人为自己的有效保单
  35. UPDATE shanglifeecif.Individual si1 SET si1.label68 = '持有有效保单' WHERE si1.scustid IN (SELECT t.customerno FROM (
  36. SELECT count(*) AS pnum,p.customerno FROM POLICY_INFORMATION p
  37. WHERE p.appflag = '有效' GROUP BY p.customerno
  38. ) t WHERE t.pnum > 0);
  39. --73 客户等级标签 Label69 钻石、白金、黄金、普通 Individual.CustClass 根据CustClass字段已有的等级值显示
  40. --UPDATE shanglifeecif.Individual si1 SET si1.Label69 = si1.CustClass where 1 = 1;
  41. UPDATE shanglifeecif.Individual si1 SET si1.Label69 = (
  42. CASE si1.CustClass
  43. WHEN 1 THEN '钻石客户'
  44. WHEN 2 THEN '白金客户'
  45. WHEN 3 THEN '黄金客户'
  46. --WHEN 4 THEN '普通级别'
  47. --ELSE '无级别'
  48. ELSE ''
  49. END
  50. ) where 1 = 1;
  51. --74 最近接触业务类型 Label70 最近投诉、最近问询(咨询)、最近营销、最近理赔、最近出险、最近保全 Individual.LCType 客户最后一次接触的业务类型
  52. --75 最近接触方式 Label71 最近外呼、最近呼入、微信 Individual.LCMethod 客户最后一次接触的方式
  53. --77 是否关注官微 Label73 关注官微 无 0
  54. UPDATE shanglifeecif.Individual si1 SET si1.Label73 = '关注官微'
  55. WHERE si1.idcard IN (SELECT a.certificate_no FROM account a)
  56. OR si1.passport IN (SELECT a.certificate_no FROM account a)
  57. OR si1.Dlicense IN (SELECT a.certificate_no FROM account a)
  58. OR si1.othernumber IN (SELECT a.certificate_no FROM account a);
  59. --78 是否注册官微 Label74 注册官微 无 0
  60. UPDATE shanglifeecif.Individual si1 SET si1.Label74 = '注册官微'
  61. WHERE si1.idcard IN (SELECT a.certificate_no FROM account a WHERE a.account_status = 0)
  62. OR si1.passport IN (SELECT a.certificate_no FROM account a WHERE a.account_status = 0)
  63. OR si1.Dlicense IN (SELECT a.certificate_no FROM account a WHERE a.account_status = 0)
  64. OR si1.othernumber IN (SELECT a.certificate_no FROM account a WHERE a.account_status = 0);
  65. -- 本人生日提醒 Label77 本人生日临近 客户生日-当前日期<5
  66. UPDATE shanglifeecif.Individual si1 SET si1.label77 = '本人生日临近' WHERE (DAYOFYEAR(sysdate(),'yyyy-MM-dd')-DAYOFYEAR(si1.birthday,'yyyy-MM-dd')) BETWEEN 1 AND 5;
  67. EXCEPTION
  68. WHEN HIVE_EXCEPTION THEN
  69. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  70. WHEN Others THEN
  71. INSERT INTO shanglifeecif.exception_log(log_code,log_msg,log_time) VALUES (sqlcode(),sqlerrm(),sysdate());
  72. END