public without sharing class OrderListHandler extends Oly_TriggerHandler {
|
|
private Map<Id, Sample_order_list__c> newMap;
|
private Map<Id, Sample_order_list__c> oldMap;
|
private List<Sample_order_list__c> newList;
|
private List<Sample_order_list__c> oldList;
|
|
public OrderListHandler() {
|
this.newMap = (Map<Id, Sample_order_list__c>) Trigger.newMap;
|
this.oldMap = (Map<Id, Sample_order_list__c>) Trigger.oldMap;
|
this.newList = (List<Sample_order_list__c>) Trigger.new;
|
this.oldList = (List<Sample_order_list__c>) Trigger.old;
|
}
|
|
protected override void afterInsert() {
|
changeStaToSent();
|
}
|
protected override void afterUpdate() {
|
changeStaToSent();
|
}
|
|
//样本订货单 状态 变为 '订单已发送' ==> 触发NFM115接口,给SAP发数据
|
private void changeStaToSent(){
|
List<String> sOrderList = new List<String>();
|
for(Sample_order_list__c orl : newList){
|
if(Trigger.isInsert){
|
if(orl.Status__c == '订单已发送'){
|
sOrderList.add(orl.Id);
|
}
|
}
|
if(Trigger.isUpdate){
|
if(oldMap.get(orl.Id) != null){
|
Sample_order_list__c oldOrl = oldMap.get(orl.Id);
|
if(orl.Status__c == '订单已发送' && oldOrl.Status__c != '订单已发送'){
|
sOrderList.add(orl.Id);
|
}
|
}
|
}
|
}
|
if(sOrderList.size() > 0){
|
BatchIF_Log__c iflog = new BatchIF_Log__c();
|
iflog.Type__c = 'NFM115';
|
iflog.Log__c = 'callout start\n';
|
insert iflog;
|
iflog = [Select Id, Name from BatchIF_Log__c where Id = :iflog.Id];
|
NFM115Controller.callout(iflog.Id, sOrderList);
|
}
|
}
|
|
}
|