From d8dc84a3d56df839895f1c417a4d9cbee763d262 Mon Sep 17 00:00:00 2001
From: 高章伟 <gaozhangwei@prec-tech.com>
Date: 星期五, 03 三月 2023 14:50:59 +0800
Subject: [PATCH] gzw 测试环境代码更新
---
force-app/main/default/classes/LostCancelReportHandler.cls | 584 +++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 398 insertions(+), 186 deletions(-)
diff --git a/force-app/main/default/classes/LostCancelReportHandler.cls b/force-app/main/default/classes/LostCancelReportHandler.cls
index b27a6a0..bfdf8a2 100644
--- a/force-app/main/default/classes/LostCancelReportHandler.cls
+++ b/force-app/main/default/classes/LostCancelReportHandler.cls
@@ -1,200 +1,412 @@
public without sharing class LostCancelReportHandler extends Oly_TriggerHandler {
- private Map<Id, Lost_cancel_report__c> newMap;
- private Map<Id, Lost_cancel_report__c> oldMap;
- private List<Lost_cancel_report__c> newList;
- private List<Lost_cancel_report__c> oldList;
+ private Map<Id, Lost_cancel_report__c> newMap;
+ private Map<Id, Lost_cancel_report__c> oldMap;
+ private List<Lost_cancel_report__c> newList;
+ private List<Lost_cancel_report__c> oldList;
- public LostCancelReportHandler() {
- this.newMap = (Map<Id, Lost_cancel_report__c>) Trigger.newMap;
- this.oldMap = (Map<Id, Lost_cancel_report__c>) Trigger.oldMap;
- this.newList = (List<Lost_cancel_report__c>) Trigger.new;
- this.oldList = (List<Lost_cancel_report__c>) Trigger.old;
- }
+ public LostCancelReportHandler() {
+ this.newMap = (Map<Id, Lost_cancel_report__c>) Trigger.newMap;
+ this.oldMap = (Map<Id, Lost_cancel_report__c>) Trigger.oldMap;
+ this.newList = (List<Lost_cancel_report__c>) Trigger.new;
+ this.oldList = (List<Lost_cancel_report__c>) Trigger.old;
+ }
- // 鏇存柊缁忕悊(閿�鍞�) 20200302 Start
- protected override void beforeUpdate() {
- // 鏇存柊缁忕悊(閿�鍞�)淇℃伅
- updateManager();
- }
- // 鏇存柊瀹℃壒浜� 20200302 End
+ // 鏇存柊缁忕悊(閿�鍞�) 20200302 Start
+ protected override void beforeUpdate() {
+ // 鏇存柊缁忕悊(閿�鍞�)淇℃伅
+ updateManager();
+ //銆怓Y23璇环鏀瑰杽銆�-P锛氫腑鏍囩粨鏋滅‘璁や换鍔″紑鍙� 20220706 鏇存柊澶卞崟浠诲姟纭鏃堕棿
+ updateLostTaskTime();
- protected override void afterUpdate() {
+ }
+ // 鏇存柊瀹℃壒浜� 20200302 End
- // 鏇存柊璇环鐨勫け鍗曚俊鎭�
- //updateLostInfo();
- updateopp(); // by tcm
- }
- /*
- private void updateLostInfo() {
- List<Opportunity> oppList = new List<Opportunity>();
- //2018骞�7鏈�16鏃� CHAN-B2HCB7 start 鑾峰彇瀛楁
- List<Lost_cancel_report__c> temLCRList =
- [select id,Opportunity__c,Report_Status__c,
- Lost_By_Company__c,Lost_reason_main__c , of_lost_system_processor__c,
- Lost_Reason_Sub__c, Lost_By_Product__c,
- CompetitorProduct1__r.id, CompetitorProduct1__r.Name,
- CompetitorProduct2__r.id, CompetitorProduct2__r.Name,
- CompetitorProduct3__r.id, CompetitorProduct3__r.Name,
- CompetitorProduct4__r.id, CompetitorProduct4__r.Name
- from Lost_cancel_report__c
- where id in: newList];
- // 2018骞�7鏈�16鏃� CHAN-B2HCB7 end 鑾峰彇瀛楁
- for (Lost_cancel_report__c n : temLCRList) {
- //Lost_cancel_report__c o = oldMap.get(n.id); && o.Report_Status__c != '鎵瑰噯'
- if (n.Report_Status__c == '鎵瑰噯' ) {
- Opportunity opp = new Opportunity();
- opp.id = n.Opportunity__c;
- opp.Lost_Cancel_Report__c = n.id;
- //2018骞�7鏈�16鏃� CHAN-B2HCB7 start 涓轰笟鍔℃満浼氬璞$殑绔炰簤瀵规墜浜у搧2銆佺珵浜夊鎵嬩骇鍝�3鍜岀珵浜夊鎵嬩骇鍝�4璧嬪��
- if (n.CompetitorProduct2__r.id == '01t10000000Tqam') {
- opp.CompetitorProduct2__c = n.Lost_By_Product__c;
- } else {
- opp.CompetitorProduct2__c = n.CompetitorProduct2__r.Name;
- }
- if (n.CompetitorProduct3__r.id == '01t10000000Tqam') {
- opp.CompetitorProduct3__c = n.Lost_By_Product__c;
- } else {
- opp.CompetitorProduct3__c = n.CompetitorProduct3__r.Name;
- }
- if (n.CompetitorProduct4__r.id == '01t10000000Tqam') {
- opp.CompetitorProduct4__c = n.Lost_By_Product__c;
- } else {
- opp.CompetitorProduct4__c = n.CompetitorProduct4__r.Name;
- }
- //2018骞�7鏈�16鏃� CHAN-B2HCB7 end 涓轰笟鍔℃満浼氬璞$殑绔炰簤瀵规墜浜у搧2銆佺珵浜夊鎵嬩骇鍝�3鍜岀珵浜夊鎵嬩骇鍝�4璧嬪��
- //2018骞�7鏈�16鏃� CHAN-B2X9SW start 涓轰笟鍔℃満浼氬璞$殑璇环閲嶅璧嬪��
- /*if (n.Cancel_Reason__c == '璇环閲嶅') {
- //opp.Opportunity_repeated_text__c = n.Opportunity_repeated__c;
- }
- //2018骞�7鏈�16鏃� CHAN-B2X9SW end 涓轰笟鍔℃満浼氬璞$殑璇环閲嶅璧嬪�� by寮犵帀灞�
- oppList.add(opp);
+ protected override void afterUpdate() {
+
+ // 鏇存柊璇环鐨勫け鍗曚俊鎭�
+ //updateLostInfo();
+ updateopp(); // by tcm
+ }
+
+ //2022-6-22 yjk 璇环璺熻繘浠诲姟 start
+ protected override void afterInsert() {
+ updateTask();
+ }
+
+ // 2022-7-29 ssm XLIU-CGSC8R 銆愬鎵樸�慬鏀瑰杽銆戣浠烽噷鍒犻櫎鎵瑰噯鐨勫け鍗曟姤鍛婄姸鎬�1鑷姩鍙�
+ protected override void afterDelete() {
+ // 鍒犻櫎宸叉壒鍑嗙殑鎶ュ憡鍚庯紝鎶婅浠风姸鎬佹敼鍥炴垚璇环
+ updateOppStage();
+ }
+
+ private void updateTask(){
+ List<Id> oppIdList = new List<Id>();
+ Set<Id> oppIdSet = new Set<Id>();
+ Set<Id> sdoppidSet = new Set<Id>();
+ List<Id> updateOppId = new List<Id>();
+ List<Opportunity> updateOpp = new List<Opportunity>();
+
+ for(Lost_cancel_report__c lcr : newList){
+ oppIdList.add(lcr.Opportunity__c);
+
+ }
+ // 20221202 ljh DB202211594688 start
+ // List<task__c> taskList = [select id,taskStatus__c,OpportunityId__c from task__c where RecordType.Name ='涓爣缁撴灉纭' and taskStatus__c = '02 鎺ュ彈' and OpportunityId__c in :oppIdList];
+ // for(task__c tsk : taskList){
+ // tsk.taskStatus__c = '03 瀹屾垚';
+ // //updateOppId.add(tsk.OpportunityId__c); //20220823 you 娌℃湁浠诲姟鏃讹紝
+ // }
+ // LoseListTask 澶卞崟鎶ュ憡浠诲姟 winBiddingTask 涓爣缁撴灉纭
+ List<task__c> taskList = [select id,taskStatus__c,OpportunityId__c,RecordType.Name from task__c where (RecordType.Name ='涓爣缁撴灉纭' or RecordType.Name ='澶卞崟鎶ュ憡浠诲姟') and OpportunityId__c in :oppIdList];
+ for(task__c tsk : taskList){
+ if(tsk.RecordType.Name == '涓爣缁撴灉纭' && tsk.taskStatus__c == '02 鎺ュ彈'){
+ tsk.taskStatus__c = '03 瀹屾垚';
+ }
+ //20221206 you DB202211594688 鍏堝仛浜嗙珵浜夊鎵嬩腑鏍囷紝鐒跺悗鍦ㄥ仛閮ㄥ垎澶卞崟锛屾竻绌�
+ if(tsk.RecordType.Name == '澶卞崟鎶ュ憡浠诲姟'){
+ sdoppidSet.add(tsk.OpportunityId__c);
+ }
+ oppIdSet.add(tsk.OpportunityId__c);
+ }
+ // for(Id oppId : oppIdList){//20220823 you
+ for(Id oppId : oppIdSet){
+ // 20221202 ljh DB202211594688 end
+ Opportunity opptemp = new Opportunity();
+ opptemp.Id = oppId ;
+ for(Lost_cancel_report__c lcr : newList){
+ //20221205 you DB202211594688 鍙栨秷寰楀け鍗曟姤鍛婁笉璁剧疆缁撴灉锛屼篃涓嶆淳鍙戜换鍔�
+ if(lcr.DeveloperName__c !='PCL_Cancel_report'){
+ opptemp.ConfirmationofAward__c = '绔炰簤瀵规墜涓爣';
+ }
+ if(null!=sdoppidSet && sdoppidSet.contains(oppId) && lcr.DeveloperName__c =='PCL_PartLost_report'){
+ opptemp.ConfirmationofAward__c = '';
+ opptemp.ConfirmationofAward_createTime__c = null;
+ opptemp.Is_ConfirmationofAward__c =null;
+ }
+
+ }
+
+ updateOpp.add(opptemp);
+ }
+
+
+ update updateOpp;
+ update taskList;
+ }
+ //2022-6-22 yjk 璇环璺熻繘浠诲姟 end
+
+ /*
+ private void updateLostInfo() {
+ List<Opportunity> oppList = new List<Opportunity>();
+ //2018骞�7鏈�16鏃� CHAN-B2HCB7 start 鑾峰彇瀛楁
+ List<Lost_cancel_report__c> temLCRList =
+ [select id,Opportunity__c,Report_Status__c,
+ Lost_By_Company__c,Lost_reason_main__c , of_lost_system_processor__c,
+ Lost_Reason_Sub__c, Lost_By_Product__c,
+ CompetitorProduct1__r.id, CompetitorProduct1__r.Name,
+ CompetitorProduct2__r.id, CompetitorProduct2__r.Name,
+ CompetitorProduct3__r.id, CompetitorProduct3__r.Name,
+ CompetitorProduct4__r.id, CompetitorProduct4__r.Name
+ from Lost_cancel_report__c
+ where id in: newList];
+ // 2018骞�7鏈�16鏃� CHAN-B2HCB7 end 鑾峰彇瀛楁
+ for (Lost_cancel_report__c n : temLCRList) {
+ //Lost_cancel_report__c o = oldMap.get(n.id); && o.Report_Status__c != '鎵瑰噯'
+ if (n.Report_Status__c == '鎵瑰噯' ) {
+ Opportunity opp = new Opportunity();
+ opp.id = n.Opportunity__c;
+ opp.Lost_Cancel_Report__c = n.id;
+ //2018骞�7鏈�16鏃� CHAN-B2HCB7 start 涓轰笟鍔℃満浼氬璞$殑绔炰簤瀵规墜浜у搧2銆佺珵浜夊鎵嬩骇鍝�3鍜岀珵浜夊鎵嬩骇鍝�4璧嬪��
+ if (n.CompetitorProduct2__r.id == '01t10000000Tqam') {
+ opp.CompetitorProduct2__c = n.Lost_By_Product__c;
+ } else {
+ opp.CompetitorProduct2__c = n.CompetitorProduct2__r.Name;
+ }
+ if (n.CompetitorProduct3__r.id == '01t10000000Tqam') {
+ opp.CompetitorProduct3__c = n.Lost_By_Product__c;
+ } else {
+ opp.CompetitorProduct3__c = n.CompetitorProduct3__r.Name;
+ }
+ if (n.CompetitorProduct4__r.id == '01t10000000Tqam') {
+ opp.CompetitorProduct4__c = n.Lost_By_Product__c;
+ } else {
+ opp.CompetitorProduct4__c = n.CompetitorProduct4__r.Name;
+ }
+ //2018骞�7鏈�16鏃� CHAN-B2HCB7 end 涓轰笟鍔℃満浼氬璞$殑绔炰簤瀵规墜浜у搧2銆佺珵浜夊鎵嬩骇鍝�3鍜岀珵浜夊鎵嬩骇鍝�4璧嬪��
+ //2018骞�7鏈�16鏃� CHAN-B2X9SW start 涓轰笟鍔℃満浼氬璞$殑璇环閲嶅璧嬪��
+ /*if (n.Cancel_Reason__c == '璇环閲嶅') {
+ //opp.Opportunity_repeated_text__c = n.Opportunity_repeated__c;
+ }
+ //2018骞�7鏈�16鏃� CHAN-B2X9SW end 涓轰笟鍔℃満浼氬璞$殑璇环閲嶅璧嬪�� by寮犵帀灞�
+ oppList.add(opp);
+ }
+ }
+ if (oppList.size() > 0) update oppList;
+ }
+ */
+ // 鏇存柊缁忕悊(閿�鍞�) 20200302 Start
+ private void updateManager() {
+ List<String> userIdList = new List<String>();
+ for (Lost_cancel_report__c n: newList) {
+ if (Trigger.isUpdate && (n.Report_Status__c != oldMap.get(n.Id).Report_Status__c) && (n.Report_Status__c == '鐢宠涓�')) {
+ userIdList.add(n.OwnerId__c);
+ }
+ }
+
+ Map<String, User> userMap = new Map<String, User>();
+ List<User> userList = [select Id, SalesManager__c from user where id =: userIdList];
+
+ for (User u : userList) {
+ String sid = u.Id;
+ userMap.put(sid.substring(0,15), u);
+ }
+
+ for (Lost_cancel_report__c n : newList) {
+ if (Trigger.isUpdate && (n.Report_Status__c != oldMap.get(n.Id).Report_Status__c) && (n.Report_Status__c == '鐢宠涓�')) {
+ if (userMap.get(n.OwnerId__c) != null) {
+ n.Manager_sales__c = userMap.get(n.OwnerId__c).SalesManager__c;
+ }
+ }
+ }
+ }
+ // 鏇存柊瀹℃壒浜� 20200302 End
+
+ // tcm 20211126 鏇存柊璇环淇℃伅 start
+ private void updateopp() {
+
+ Set<String> oppIdPZSet = new Set<String>(); // 20221202 ljh DB202211594688 start // 澶卞崟鎶ュ憡鎵瑰噯鍚庯紝鑷姩璁剧疆绔炰簤瀵规墜涓爣鍜屼腑鏍囩粨鏋滅‘璁ゆ棩
+ // 娓呴櫎涓嶉渶瑕佹洿鏂扮殑
+ Map<Id,Lost_cancel_report__c> arrMap=new Map<Id,Lost_cancel_report__c>();
+ for (String newlcro : newMap.keyset()) {
+ if (newMap.get(newlcro).Report_Status__c=='鎵瑰噯'&&oldMap.get(newlcro).Report_Status__c!='鎵瑰噯') {
+ arrMap.put(newlcro,newMap.get(newlcro));
+ // 20221202 ljh DB202211594688 start
+ // 澶卞崟鎶ュ憡浠诲姟鐨勮浠�
+ if(String.isNotBlank(newMap.get(newlcro).Opportunity__c) && newMap.get(newlcro).DeveloperName__c == 'PCL_Lost_report'){
+ oppIdPZSet.add(newMap.get(newlcro).Opportunity__c);
+ }
+ // 20221202 ljh DB202211594688 end
+ }
+ }
+
+ //20220708 璇环浠诲姟寮�鍙戯紝缁撴潫澶卞崟浠诲姟鐘舵�侊紝绛涢�夐渶瑕佺殑淇敼鐨勫け鍗曚换鍔� start
+ Set<String> oppIdSet = new Set<String>();
+ for (Lost_cancel_report__c n: newList) {
+ if ((n.Report_Status__c != oldMap.get(n.Id).Report_Status__c) && n.Report_Status__c == '鐢宠涓�') {
+ oppIdSet.add(n.Opportunity__c);
+ }
+ }
+ // 20220720 ljh add 璁板綍鍙栨秷/澶卞崟鎶ュ憡鎻愪氦鏃剁偣鐨勬垬鐣ヤ骇鍝佸垽鏂� start
+ if(oppIdSet.size() > 0 ){
+ List<OpportunityLineItem> OppLIlist = [select Id,Key_product_147P_Text__c,Key_product_147P__c from OpportunityLineItem where OpportunityId in :oppIdSet];
+ for(OpportunityLineItem oli : OppLIlist){
+ oli.Key_product_147P_Text__c = oli.Key_product_147P__c;
+ }
+ update OppLIlist;
+ // 20220720 ljh add 璁板綍鍙栨秷/澶卞崟鎶ュ憡鎻愪氦鏃剁偣鐨勬垬鐣ヤ骇鍝佸垽鏂� end
+ List<task__c> taskList = [select id,taskStatus__c from task__c where RecordType.Name ='澶卞崟鎶ュ憡浠诲姟' and taskStatus__c = '02 鎺ュ彈' and OpportunityId__c in :oppIdSet];
+ for(task__c tsk : taskList){
+ tsk.taskStatus__c = '03 瀹屾垚';
}
- }
- if (oppList.size() > 0) update oppList;
- }
- */
- // 鏇存柊缁忕悊(閿�鍞�) 20200302 Start
- private void updateManager() {
- List<String> userIdList = new List<String>();
- for (Lost_cancel_report__c n: newList) {
- if (Trigger.isUpdate && (n.Report_Status__c != oldMap.get(n.Id).Report_Status__c) && (n.Report_Status__c == '鐢宠涓�')) {
- userIdList.add(n.OwnerId__c);
- }
- }
+ update taskList;
+ }// 20220720 ljh update
+ //20220708 璇环浠诲姟寮�鍙戯紝缁撴潫澶卞崟浠诲姟鐘舵�侊紝绛涢�夐渶瑕佺殑淇敼鐨勫け鍗曚换鍔� end
- Map<String, User> userMap = new Map<String, User>();
- List<User> userList = [select Id, SalesManager__c from user where id =: userIdList];
+ List<PCLLostProduct__c> lcrList=[select id,PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c,
+ PCLLostBrand__r.Lost_Reason_Sub__c,PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c,
+ PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c, //20230215 lt DB202302247719
+ PCLLostBrand__r.Lost_cancel_report__r.LostType__c,PCLLostBrand__r.Lost_By_Company__c,
+ PCLLostBrand__r.Lost_By_Company_Mannual__c,PCLLostBrand__r.LostPrice__c,LostProduct__r.Name,
+ PCLLostBrand__r.Lost_reason_main__c,PCLLostBrand__r.Agency__r.Name,PCLLostBrand__r.AgencyMannual__c,
+ PCLLostBrand__r.Lost_cancel_report__r.Opportunity__r.Name,Opportunity__c, LostProductMannual__c
+ ,ProductClass__c, Quantity__c //20220930 lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟
+ from PCLLostProduct__c
+ where PCLLostBrand__r.Lost_cancel_report__c in : arrMap.keyset()];
+ List<Opportunity> oppList=new List<Opportunity>();
+ for (String lcro : arrMap.keyset()) {
+ // 缁欎骇鍝佽祴鍊�
+ Integer i=0;
+ //璧嬪�艰浠峰幓閲�
+ List<String> jxsList=new List<String>(); //缁忛攢鍟�
+ List<String> ppList=new List<String>(); //澶卞崟鍝佺墝
+ // List<String> yyList=new List<String>(); //澶卞崟鍘熷洜
+ //鍒濆鍖�
+ Opportunity opp=new Opportunity();
+ //20220930 lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 start
+ opp.RivalHostsNumber__c = 0;
+ //20220930 lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
+ opp.Id=arrMap.get(lcro).Opportunity__c; opp.PCLLostBrands__c=''; opp.Agencies__c=''; //Id ,鍝佺墝,缁忛攢鍟�
+ // for浜у搧
+ for (PCLLostProduct__c lcr : lcrList) {
+ if (opp.Id==lcr.Opportunity__c) {
- for (User u : userList) {
- String sid = u.Id;
- userMap.put(sid.substring(0,15), u);
- }
+ //20220930 lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 start
+ if(lcr.ProductClass__c == '涓绘満'){
+ opp.RivalHostsNumber__c += lcr.Quantity__c;
+ }else{
+ opp.RivalHostsNumber__c += 0;
+ }
+ //20220930 lt SWAG-CHL5XA銆怓Y23璇环鏀瑰杽銆�-缁熻涓绘満鍙版暟 end
- for (Lost_cancel_report__c n : newList) {
- if (Trigger.isUpdate && (n.Report_Status__c != oldMap.get(n.Id).Report_Status__c) && (n.Report_Status__c == '鐢宠涓�')) {
- if (userMap.get(n.OwnerId__c) != null) {
- n.Manager_sales__c = userMap.get(n.OwnerId__c).SalesManager__c;
- }
- }
- }
- }
- // 鏇存柊瀹℃壒浜� 20200302 End
+ i++;
+ //缁欒浠蜂笉鍚屽瓧娈佃祴鍊� 澶卞崟
+ if (lcr.PCLLostBrand__r.Lost_cancel_report__r.LostType__c=='澶卞崟') {
+ if (i==1) {
+ opp.CompetitorProduct1__c=lcr.LostProduct__r.Name != null ? lcr.LostProduct__r.Name : lcr.LostProductMannual__c;
+ }else if (i==2) {
+ opp.CompetitorProduct2__c=lcr.LostProduct__r.Name != null ? lcr.LostProduct__r.Name : lcr.LostProductMannual__c;
+ }else if (i==3) {
+ opp.CompetitorProduct3__c=lcr.LostProduct__r.Name != null ? lcr.LostProduct__r.Name : lcr.LostProductMannual__c;
+ }
+ }
+ // 澶卞崟鐞嗙敱
+ if (i==1) {
+ opp.Lost_reason_main__c=lcr.PCLLostBrand__r.Lost_reason_main__c;
+ opp.Lost_Reason_Sub__c=lcr.PCLLostBrand__r.Lost_Reason_Sub__c;
- // tcm 20211126 鏇存柊璇环淇℃伅 start
- private void updateopp() {
- // 娓呴櫎涓嶉渶瑕佹洿鏂扮殑
- Map<Id,Lost_cancel_report__c> arrMap=new Map<Id,Lost_cancel_report__c>();
- for (String newlcro : newMap.keyset()) {
- if (newMap.get(newlcro).Report_Status__c=='鎵瑰噯'&&oldMap.get(newlcro).Report_Status__c!='鎵瑰噯') {
- arrMap.put(newlcro,newMap.get(newlcro));
- }
- }
- List<PCLLostProduct__c> lcrList=[select id,PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c,PCLLostBrand__r.Lost_Reason_Sub__c,PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c,PCLLostBrand__r.Lost_cancel_report__r.LostType__c,PCLLostBrand__r.Lost_By_Company__c,PCLLostBrand__r.Lost_By_Company_Mannual__c,PCLLostBrand__r.LostPrice__c,LostProduct__r.Name, PCLLostBrand__r.Lost_reason_main__c,PCLLostBrand__r.Agency__r.Name,PCLLostBrand__r.AgencyMannual__c,PCLLostBrand__r.Lost_cancel_report__r.Opportunity__r.Name,Opportunity__c, LostProductMannual__c from PCLLostProduct__c where PCLLostBrand__r.Lost_cancel_report__c in : arrMap.keyset()];
- List<Opportunity> oppList=new List<Opportunity>();
- for (String lcro : arrMap.keyset()) {
- // 缁欎骇鍝佽祴鍊�
- Integer i=0;
- //璧嬪�艰浠峰幓閲�
- List<String> jxsList=new List<String>(); //缁忛攢鍟�
- List<String> ppList=new List<String>(); //澶卞崟鍝佺墝
- // List<String> yyList=new List<String>(); //澶卞崟鍘熷洜
- //鍒濆鍖�
- Opportunity opp=new Opportunity();
- opp.Id=arrMap.get(lcro).Opportunity__c; opp.PCLLostBrands__c=''; opp.Agencies__c=''; //Id ,鍝佺墝,缁忛攢鍟�
- // for浜у搧
- for (PCLLostProduct__c lcr : lcrList) {
- if (opp.Id==lcr.Opportunity__c) {
- i++;
- //缁欒浠蜂笉鍚屽瓧娈佃祴鍊� 澶卞崟
- if (lcr.PCLLostBrand__r.Lost_cancel_report__r.LostType__c=='澶卞崟') {
- if (i==1) {
- opp.CompetitorProduct1__c=lcr.LostProduct__r.Name != null ? lcr.LostProduct__r.Name : lcr.LostProductMannual__c;
- }else if (i==2) {
- opp.CompetitorProduct2__c=lcr.LostProduct__r.Name != null ? lcr.LostProduct__r.Name : lcr.LostProductMannual__c;
- }else if (i==3) {
- opp.CompetitorProduct3__c=lcr.LostProduct__r.Name != null ? lcr.LostProduct__r.Name : lcr.LostProductMannual__c;
- }
- }
- // 澶卞崟鐞嗙敱
- if (i==1) {
- opp.Lost_reason_main__c=lcr.PCLLostBrand__r.Lost_reason_main__c;
- opp.Lost_Reason_Sub__c=lcr.PCLLostBrand__r.Lost_Reason_Sub__c;
-
- }
+ }
- //缁忛攢鍟�
- if (!jxsList.contains(lcr.PCLLostBrand__r.Agency__r.Name)) {
- jxsList.add(lcr.PCLLostBrand__r.Agency__r.Name);
- if (jxsList.size()==1) {
- if (lcr.PCLLostBrand__r.AgencyMannual__c==null) {
- opp.Agencies__c+=lcr.PCLLostBrand__r.Agency__r.Name;
- }else {
- opp.Agencies__c+=lcr.PCLLostBrand__r.AgencyMannual__c;
- }
- }else {
- if (lcr.PCLLostBrand__r.AgencyMannual__c==null) {
- opp.Agencies__c+='锛�'+lcr.PCLLostBrand__r.Agency__r.Name;
- }else {
- opp.Agencies__c+='锛�'+lcr.PCLLostBrand__r.AgencyMannual__c;
- }
- }
- }
- //澶卞崟鍝佺墝
- if (!ppList.contains(lcr.PCLLostBrand__r.Lost_By_Company__c)) {
- ppList.add(lcr.PCLLostBrand__r.Lost_By_Company__c);
- if (ppList.size()==1) {
- if (lcr.PCLLostBrand__r.Lost_By_Company__c=='鍏朵粬') {
- opp.PCLLostBrands__c+=lcr.PCLLostBrand__r.Lost_By_Company_Mannual__c;
- }else {
- opp.PCLLostBrands__c+=lcr.PCLLostBrand__r.Lost_By_Company__c;
- }
- }else {
- if (lcr.PCLLostBrand__r.Lost_By_Company__c=='鍏朵粬') {
- opp.PCLLostBrands__c+=','+lcr.PCLLostBrand__r.Lost_By_Company_Mannual__c;
- }else {
- opp.PCLLostBrands__c+=','+lcr.PCLLostBrand__r.Lost_By_Company__c;
- }
- }
- }
- // //澶卞崟鍘熷洜
- // if (!yyList.contains(lcr.PCLLostBrand__r.Lost_reason_main__c)) {
- // yyList.add(lcr.PCLLostBrand__r.Lost_reason_main__c);
- // if (yyList.size()==1) {
- // opp.Lost_reason_mains__c+=lcr.PCLLostBrand__r.Lost_reason_main__c+'锛�';
- // }else {
- // opp.Lost_reason_mains__c+='锛�'+lcr.PCLLostBrand__r.Lost_reason_main__c;
- // }
- // }
- //澶卞崟鎬婚噾棰�
- opp.LostPrices__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c;
- opp.of_lost_system_processor__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c;
- }
- }
- oppList.add(opp);
- }
- update oppList;
- }
- // tcm 20211126 鏇存柊璇环淇℃伅 end
+ //缁忛攢鍟�
+ if (!jxsList.contains(lcr.PCLLostBrand__r.Agency__r.Name)) {
+ jxsList.add(lcr.PCLLostBrand__r.Agency__r.Name);
+ // SWAG-CCC6F6 2022-04-22 ssm start
+ // 璇环涓婇兘鍙樉绀洪�夐」鍒楄〃鐨勫�硷紝涓嶉渶瑕佹墜鍔ㄧ殑鍊�
+ if (jxsList.size()==1) {
+ // if (lcr.PCLLostBrand__r.AgencyMannual__c==null) {
+ // opp.Agencies__c+=lcr.PCLLostBrand__r.Agency__r.Name;
+ // }else {
+ // opp.Agencies__c+=lcr.PCLLostBrand__r.AgencyMannual__c;
+ // }
+ opp.Agencies__c+=lcr.PCLLostBrand__r.Agency__r.Name;
+ }else {
+ // if (lcr.PCLLostBrand__r.AgencyMannual__c==null) {
+ // opp.Agencies__c+='锛�'+lcr.PCLLostBrand__r.Agency__r.Name;
+ // }else {
+ // opp.Agencies__c+='锛�'+lcr.PCLLostBrand__r.AgencyMannual__c;
+ // }
+ opp.Agencies__c+='锛�'+lcr.PCLLostBrand__r.Agency__r.Name;
+ }
+ // SWAG-CCC6F6 2022-04-22 ssm end
+ }
+ //澶卞崟鍝佺墝
+ if (!ppList.contains(lcr.PCLLostBrand__r.Lost_By_Company__c)) {
+ ppList.add(lcr.PCLLostBrand__r.Lost_By_Company__c);
+ // SWAG-CCC6F6 2022-04-22 ssm start
+ // 璇环涓婇兘鍙樉绀洪�夐」鍒楄〃鐨勫�硷紝涓嶉渶瑕佹墜鍔ㄧ殑鍊�
+ if (ppList.size()==1) {
+ // if (lcr.PCLLostBrand__r.Lost_By_Company__c=='鍏朵粬') {
+ // opp.PCLLostBrands__c+=lcr.PCLLostBrand__r.Lost_By_Company_Mannual__c;
+ // }else {
+ // opp.PCLLostBrands__c+=lcr.PCLLostBrand__r.Lost_By_Company__c;
+ // }
+ opp.PCLLostBrands__c+=lcr.PCLLostBrand__r.Lost_By_Company__c;
+ }else {
+ // if (lcr.PCLLostBrand__r.Lost_By_Company__c=='鍏朵粬') {
+ // opp.PCLLostBrands__c+=','+lcr.PCLLostBrand__r.Lost_By_Company_Mannual__c;
+ // }else {
+ // opp.PCLLostBrands__c+=','+lcr.PCLLostBrand__r.Lost_By_Company__c;
+ // }
+ opp.PCLLostBrands__c+=','+lcr.PCLLostBrand__r.Lost_By_Company__c;
+ }
+ // SWAG-CCC6F6 2022-04-22 ssm end
+ }
+ // //澶卞崟鍘熷洜
+ // if (!yyList.contains(lcr.PCLLostBrand__r.Lost_reason_main__c)) {
+ // yyList.add(lcr.PCLLostBrand__r.Lost_reason_main__c);
+ // if (yyList.size()==1) {
+ // opp.Lost_reason_mains__c+=lcr.PCLLostBrand__r.Lost_reason_main__c+'锛�';
+ // }else {
+ // opp.Lost_reason_mains__c+='锛�'+lcr.PCLLostBrand__r.Lost_reason_main__c;
+ // }
+ // }
+ //澶卞崟鎬婚噾棰�
+ //opp.LostPrices__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.LostTotalAmount__c;//20230215 lt DB202302247719 娉ㄩ噴
+ opp.LostPrices__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.TotalAmountLost__c; //20230215 lt DB202302247719
+ opp.of_lost_system_processor__c=lcr.PCLLostBrand__r.Lost_cancel_report__r.of_lost_system_processor__c;
+ }
+ }
+ // 20221202 ljh DB202211594688 start
+ System.debug('zheli00:'+oppIdPZSet+'~'+opp.Id);
+ if(oppIdPZSet.contains(opp.Id)){
+ opp.ConfirmationofAward__c = '绔炰簤瀵规墜涓爣';
+ opp.Closing_Bid_Date__c = null;
+ }
+ // 20221202 ljh DB202211594688 start
+ oppList.add(opp);
+ }
+ update oppList;
+
+ }
+ // tcm 20211126 鏇存柊璇环淇℃伅 end
+
+
+ //sx 20220706 銆怓Y23璇环鏀瑰杽銆�-P锛氫腑鏍囩粨鏋滅‘璁や换鍔″紑鍙� 澶卞崟浠诲姟纭鏃堕棿 start
+ private void updateLostTaskTime(){
+ //杩囨护闇�瑕佷慨鏀圭殑鏁版嵁
+ Set<Id> lostIds = new Set<Id>();
+ Set<Id> oppIds = new Set<Id>();
+ for(Lost_cancel_report__c lcr : newList){
+ //绛涢�夊嚭闇�瑕佹彁浜ゆ棩鏈変慨鏀圭殑璁㈠崟
+ Lost_cancel_report__c oldLrc = oldMap.get(lcr.Id);
+ if((lcr.Report_Status__c != oldMap.get(lcr.Id).Report_Status__c) && lcr.Report_Status__c == '鐢宠涓�'){ //oldLrc.Submit_Day__c != lcr.Submit_Day__c
+ lostIds.add(lcr.Id);
+ oppIds.add(lcr.Opportunity__c);
+ }
+ }
+
+ List<Opportunity> oppList = [select Id, Task_createTime__c,LostTask_createTime__c from Opportunity where Id in :oppIds];
+ Map<Id, Opportunity> oppMap = new Map<Id, Opportunity>();
+ for(Opportunity op : oppList){
+ oppMap.put(op.Id,op);
+ }
+
+ //寰呮洿鏂扮殑璇环List
+ List<Opportunity> updateoppList = new List<Opportunity>();
+ if(!lostIds.isEmpty()){
+
+ for(String lostId : lostIds){
+ Lost_cancel_report__c tempLost = newMap.get(lostId);
+ //淇敼澶卞崟瀵瑰簲璇环鐨勫け鍗曚换鍔℃椂闂�
+ Opportunity opp = new Opportunity();
+ opp.Id = tempLost.Opportunity__c;
+ //20221207 澶卞崟浠诲姟纭鏃� 鍙窡澶卞崟鎶ュ憡绉板垱寤烘棩鏈夊叧绯诲幓鎺夐�昏緫 oppMap.get(tempLost.Opportunity__c).Task_createTime__c!= null ||
+ if(oppMap.get(tempLost.Opportunity__c).LostTask_createTime__c!= null){
+ opp.LostTask_comfirmTime__c = Date.today();
+ }
+ updateoppList.add(opp);
+ }
+
+ if(!updateoppList.isEmpty()){
+ update updateoppList;
+ }
+ }
+ }
+ //sx 20220706 銆怓Y23璇环鏀瑰杽銆�-P锛氫腑鏍囩粨鏋滅‘璁や换鍔″紑鍙� 澶卞崟浠诲姟纭鏃堕棿 end
+
+ // 2022-7-29 ssm XLIU-CGSC8R 銆愬鎵樸�慬鏀瑰杽銆戣浠烽噷鍒犻櫎鎵瑰噯鐨勫け鍗曟姤鍛婄姸鎬�1鑷姩鍙� start
+ // 鍒犻櫎宸叉壒鍑嗙殑鎶ュ憡鍚庯紝鎶婅浠风姸鎬佹敼鍥炴垚璇环
+ private void updateOppStage() {
+ List<String> oppIds = new List<String>();
+ for (Lost_cancel_report__c report : this.oldList) {
+ if (report.Report_Status__c == '鎵瑰噯') {
+ oppIds.add(report.Opportunity__c);
+ }
+ }
+ System.debug('oppIds: ' + oppIds);
+ if (oppIds.size() > 0) {
+ List<Opportunity> opps = [select Id, StageName, Final_Contract_Proceeded_Date__c, Lost_Opportunity_Date__c from Opportunity where Id in :oppIds and StageName in ('鏁楁垿', '鍓婇櫎')];
+ System.debug('opps: ' + opps);
+ if (opps.size() > 0) {
+ for (Opportunity opp : opps) {
+ opp.StageName = '寮曞悎';
+ opp.Final_Contract_Proceeded_Date__c = null;
+ opp.Lost_Opportunity_Date__c = null;
+ }
+ update opps;
+ }
+ }
+ }
+ // 2022-7-29 ssm XLIU-CGSC8R 銆愬鎵樸�慬鏀瑰杽銆戣浠烽噷鍒犻櫎鎵瑰噯鐨勫け鍗曟姤鍛婄姸鎬�1鑷姩鍙� end
}
\ No newline at end of file
--
Gitblit v1.9.1