From 1b1347f2e6d40aa75bbfdfb4789d60efeff13ea8 Mon Sep 17 00:00:00 2001
From: GWY <guweiyiscp096@foxmail.com>
Date: 星期五, 15 四月 2022 09:41:12 +0800
Subject: [PATCH] LS内贸未发货和以后的不显示二级经营证(临时)
---
force-app/main/default/classes/ProRegisterHandler.cls | 117 ++++++++++++++--------------------------------------------
1 files changed, 29 insertions(+), 88 deletions(-)
diff --git a/force-app/main/default/classes/ProRegisterHandler.cls b/force-app/main/default/classes/ProRegisterHandler.cls
index d3ab708..f290e50 100644
--- a/force-app/main/default/classes/ProRegisterHandler.cls
+++ b/force-app/main/default/classes/ProRegisterHandler.cls
@@ -98,95 +98,36 @@
if (UpdProMap.keySet().size() > 0) update UpdProMap.values();
}
- //浜у搧闄嶇被,鍙娉ㄥ唽璇佹洿鏂颁簡,灏辨鏌ヤ竴閬嶏紝閲嶆柊缁欎骇鍝佷笂鐨勭瓑绾х被鍒瓧娈佃祴鍊笺��
- //鍙互鎵惧嚭闇�瑕佺殑Id,鐒跺悗璋冪敤鏂规硶銆�
+ //鐢ㄤ簬闄嶇被,浜у搧娉ㄥ唽璇佹洿鏂颁簡,灏辨妸浜у搧娉ㄥ唽璇佷笅鐨勪骇鍝佺殑绛夌骇绫诲埆瀛楁璧嬬┖,瑙﹀彂浜у搧鐨勮Е鍙戝櫒
public static void checkRegistervervaldatum(List<Product_Register__c> newList, Map<Id, Product_Register__c> newMap, List<Product_Register__c> oldList, Map<Id, Product_Register__c> oldMap) {
- if (Trigger.isAfter && Trigger.isUpdate) {
- List<String> prcList = new List<String>();
- for (Product_Register__c pr : newList) {
- Product_Register__c oldpr = oldMap.get(pr.Id);
- //鏈夋晥鏈熺殑濮嬩笌缁堝彉浜�,灏辨妸杩欎釜浜у搧娉ㄥ唽璇佺殑id鏀惧叆涓�涓狶ist闆嗗悎閲岄潰
- //if (pr.ValidTo__c != oldpr.ValidTo__c || pr.ValidFrom__c != oldpr.ValidFrom__c) {
- prcList.add(pr.id);
- //}
- }
- //鏀惧埌Map閲岋紝鐢ㄤ簬鎰熻娉ㄥ唽璇佹洿鏂颁骇鍝�
- Map<Id,Product2> prt2Map = new Map<Id,Product2>();
- //閫氳繃涔嬪墠瀛樺偍鐨処d鐢ㄤ簬鍏崇郴琛ㄧ殑鏌ヨ銆�
- List<Product_Register_Link__c> prlList = new List<Product_Register_Link__c>();
- prlList = [select Product2__r.id,Product2__r.demoteer_Sap__c,Product_Register__r.MedPrdClass__c,Product_Register__r.ValidTo__c,Product_Register__r.ValidFrom__c
- from Product_Register_Link__c
- where Product_Register__r.Id in : prcList];
-
- //瀛樻斁浜у搧鐨刬d鍜岀瓑绾х被鍒瓧娈电殑鍊肩殑闆嗗悎
- Map<Id,List<String>> pro2Map = new Map<Id,List<String>>();
- if (prlList.size()>0) {
- for (Product_Register_Link__c prl: prlList) {
- if (pro2Map.containsKey(prl.Product2__r.Id)) {
- pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c);
- }else {
- pro2Map.put(prl.Product2__r.Id, new List<String>());
- pro2Map.get(prl.Product2__r.Id).add(prl.Product_Register__r.MedPrdClass__c);
- }
- }
- }
-
- //瀛樻斁浜у搧id鍜屽瓧绗︿覆鍊�
- Map<Id,String> prlMap = new Map<Id,String>();
- System.debug('pro2Map='+pro2Map);
-
- List<Id> pidList = new List<Id>();
- //閫氳繃涓婇潰鐨勫惊鐜紝鎶婂叧绯昏〃杩囪幏鍙栫殑鏁版嵁璇诲嚭鏉ワ紝浼犵粰map
- if (pro2Map.size()>0) {
- for (Product_Register_Link__c pr: prlList) {
- // && (oldMap.get(pr.Product_Register__r.Id).ValidTo__c != newMap.get(pr.Product_Register__r.Id).ValidTo__c || oldMap.get(pr.Product_Register__r.Id).ValidFrom__c != newMap.get(pr.Product_Register__r.Id).ValidFrom__c)
- if (pro2Map.containsKey(pr.Product2__r.Id)) {
- pidList.add(pr.Product2__r.Id);
- //鐢熶骇鏃ユ湡鍦ㄦ敞鍐岃瘉鏈夋晥鏈熷唴鐨勬槸浜岀被锛岀敓浜ф棩鏈熷湪澶囨璇佹湁鏁堟湡鐨勬槸涓�绫伙紝鍓嶆彁涓烘湁鏁堟湡
- // System.debug('pr.Product_Register__r.ValidTo__c='+ pr.Product_Register__r.ValidTo__c);
- // System.debug('pr.Product_Register__r.Level_Category__c='+pr.Product_Register__r.MedPrdClass__c);
- // System.debug('pr.Product2__r.demoteer_Sap__c='+ pr.Product2__r.demoteer_Sap__c);
- if (pr.Product2__r.demoteer_Sap__c <= newMap.get(pr.Product_Register__r.Id).ValidTo__c && pr.Product2__r.demoteer_Sap__c >= newMap.get(pr.Product_Register__r.Id).ValidFrom__c
- && (pr.Product_Register__r.MedPrdClass__c == '1')) {
- prlMap.put(pr.Product2__r.Id, '涓�绫�');
- }
- else if (pr.Product2__r.demoteer_Sap__c <= newMap.get(pr.Product_Register__r.Id).ValidTo__c && pr.Product2__r.demoteer_Sap__c >= newMap.get(pr.Product_Register__r.Id).ValidFrom__c
- && pr.Product_Register__r.MedPrdClass__c == '2' || pr.Product_Register__r.MedPrdClass__c == '3') {
- if (!'涓�绫�'.equals(prlMap.get(pr.Product2__r.Id))){
- prlMap.put(pr.Product2__r.Id, '浜岀被');
- }
- }
- }
- //System.debug('prlMap='+prlMap);
- }
- }
-
- List<Product2> por2Lsit = new List<Product2>();
- //鏌ュ嚭浜у搧鐨刬d鍜岀瓑绾х被鍒殑瀛楁
- por2Lsit = [select Id,Level_Category__c from Product2 where Id in : pidList];
-
- //List<Product2> ppr2List = new List<Product2>();
- //缁欎骇鍝佷笂鐨勭瓑绾х被鍒瓧娈佃祴鍊�
- for (Product2 pr2: por2Lsit) {
- //Product2 ppr2;
- if (!pro2Map.containsKey(pr2.Id)) {
- pr2.Level_Category__c = '闈炵洃绠�';
- }else if (prlMap.containsKey(pr2.Id)) {
- pr2.Level_Category__c = prlMap.get(pr2.Id);
- }else {
- pr2.Level_Category__c = null;
- }
- if (pr2.Level_Category__c != null) {
- prt2Map.put(pr2.Id, pr2);
- }
- //prt2.Id = pr2.Id;
- //prt2.Level_Category__c = pr2.Level_Category__c;
- //ppr2List.add(ppr2);
- //System.debug('ppr2List='+ppr2List);
- //System.debug('pr2.Level_Category__c='+pr2.Level_Category__c);
- }
- update prt2Map.values();
+ List<String> prcList = new List<String>();
+ for (Product_Register__c pr : newList) {
+ Product_Register__c oldpr = oldMap.get(pr.Id);
+ prcList.add(pr.id);
}
- }
+ //鏀惧埌Map閲岋紝鐢ㄤ簬娉ㄥ唽璇佹洿鏂颁骇鍝�
+ Map<Id,Product2> prt2Map = new Map<Id,Product2>();
+ //閫氳繃涔嬪墠瀛樺偍鐨処d鐢ㄤ簬鍏崇郴琛ㄧ殑鏌ヨ銆�
+ List<Product_Register_Link__c> prlList = new List<Product_Register_Link__c>();
+ prlList = [select Product2__r.id,Product2__r.demoteer_Sap__c,Product2__r.Diedatvanink__c,Product_Register__r.MedPrdClass__c,Product_Register__r.Stelsedag__c,Product_Register__r.ValidTo__c,Product_Register__r.ValidFrom__c
+ from Product_Register_Link__c
+ where Product_Register__r.Id in : prcList];
+ List<ID> proIdList = new List<ID>();
+ for (Product_Register_Link__c prl: prlList) {
+ proIdList.add(prl.Product2__r.id);
+ }
+
+ List<Product2> por2Lsit = new List<Product2>();
+ //鏌ュ嚭浜у搧鐨刬d鍜岀瓑绾х被鍒殑瀛楁
+ por2Lsit = [select Id,Level_Category__c from Product2 where Id in : proIdList];
+ for (Product2 pro: por2Lsit) {
+ pro.Level_Category__c = null;
+ prt2Map.put(pro.Id, pro);
+ }
+ System.debug('prt2Map='+prt2Map);
+ if (prt2Map.size() > 0) {
+ update prt2Map.values();
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.1