public with sharing class InquiryPredictsDateChangeHandler extends Oly_TriggerHandler{
|
|
private List<InquiryPredictsDateChange__c> oldList;
|
private List<InquiryPredictsDateChange__c> newList;
|
private Map<Id,InquiryPredictsDateChange__c> oldMap;
|
private Map<Id,InquiryPredictsDateChange__c> newMap;
|
|
public InquiryPredictsDateChangeHandler() {
|
this.oldList = (List<InquiryPredictsDateChange__c>) Trigger.old;
|
this.newList = (List<InquiryPredictsDateChange__c>) Trigger.new;
|
this.oldMap = (Map<Id,InquiryPredictsDateChange__c>) Trigger.oldMap;
|
this.newMap = (Map<Id,InquiryPredictsDateChange__c>) Trigger.newMap;
|
}
|
|
protected override void afterUpdate() {
|
addColumn();
|
}
|
|
//当审批流程走完时 更新 询价相关字段
|
private void addColumn(){
|
List<Opportunity> oppList = new List<Opportunity>();
|
Map<Id,Opportunity> oppMap = new Map<Id,Opportunity>();
|
List<Id> oppIdList = new List<Id>();
|
|
for (InquiryPredictsDateChange__c ipd :newList ) {
|
//判断更新前后的状态是否不同 若不同,则判断更新后的状态是否为'已批准'
|
if ((ipd.Predicted_Date_Status__c != oldMap.get(ipd.Id).Predicted_Date_Status__c) && ipd.Predicted_Date_Status__c == '已批准' ) {
|
String oppId = ipd.Opportunity__c ;
|
Opportunity opp = new Opportunity();
|
|
opp.Id = oppId;
|
// opp.Close_Forecasted_Assume_Date__c = ipd.Close_Forecasted_Assume_Date__c; //担当日
|
opp.Close_Forecasted_Date__c = ipd.Close_Forecasted_Date__c; //KPI日
|
opp.CloseDate = ipd.CloseDate__c; //结束日期/预测发货日
|
opp.Date_InAdvance_Delay__c = ipd.Date_InAdvance_Delay__c; //日期提前/延后
|
opp.Predicted_date_ChangeReason__c = ipd.Predicted_date_ChangeReason__c; //改变预测日期原因
|
// opp.Opp_New_Mark__c = ipd.Opp_New_Mark__c; //询价新建标记
|
opp.Opp_Delay_Mark__c = ipd.Opp_Delay_Mark__c; //询价延后标价
|
opp.ForecastApprovalTime__c = Datetime.now();
|
|
oppList.add(opp);
|
|
}
|
}
|
|
if (oppList.size() > 0) {
|
System.debug('lt123oppList'+oppList);
|
update oppList;
|
}
|
}
|
|
}
|