public without sharing class TargetCustomerHandler extends Oly_TriggerHandler {
    private Map<Id, Account_Number_of_target__c> newMap;
    private Map<Id, Account_Number_of_target__c> oldMap;
    private List<Account_Number_of_target__c> newList;
    private List<Account_Number_of_target__c> oldList;

    public TargetCustomerHandler() {

        this.newMap = (Map<Id, Account_Number_of_target__c>) Trigger.newMap;
        this.oldMap = (Map<Id, Account_Number_of_target__c>) Trigger.oldMap;
        this.newList = (List<Account_Number_of_target__c>) Trigger.new;
        this.oldList = (List<Account_Number_of_target__c>) Trigger.old;
    }
    protected override void beforeInsert() {
        updateTargetCustomer();
    }

    protected override void beforeUpdate() {
        updateTargetCustomer();

    }



    private void updateTargetCustomer() {
        Boolean flag = false ;
        for (Account_Number_of_target__c anot : newList) {

            if (Trigger.isInsert) {
                if (anot.Target_amount_290Miro__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_3D__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_CHS400XZ__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_CV170__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_CV190__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_CV290__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_EUME2__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_OERAW__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_OTVS190__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_OTVS400__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_UCES3__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_USG400__c != null) {
                    flag = true ;
                }

                if (anot.Target_amount_GW__c != null) {
                    flag = true ;
                }

                if (anot.Department_Budget_Sum_Price__c != null) {
                    flag = true ;
                }

                // SWAG-BC832V  CYF 更改也记录 更改者 start
                if (anot.Target_amount_CYF__c != null) {
                    flag = true ;
                }

                if (anot.OPD_amount_CYF__c != null) {
                    flag = true ;
                }
                // SWAG-BC832V CYF 更改也记录 更改者 end

                if (anot.OPD_290Miro__c != null) {
                    flag = true ;
                }


                if (anot.OPD_3D__c != null) {
                    flag = true ;
                }

                if (anot.OPD_CHS400XZ__c != null) {
                    flag = true ;
                }

                if (anot.OPD_CV170__c != null) {
                    flag = true ;
                }

                if (anot.OPD_CV190__c != null) {
                    flag = true ;
                }

                if (anot.OPD_CV290__c != null) {
                    flag = true ;
                }

                if (anot.OPD_EUME2__c != null) {
                    flag = true ;
                }

                if (anot.OPD_OERAW__c != null) {
                    flag = true ;
                }

                if (anot.OPD_OTVS190__c != null) {
                    flag = true ;
                }

                if (anot.OPD_OTVS400__c != null) {
                    flag = true ;
                }

                if (anot.OPD_UCES3__c != null) {
                    flag = true ;
                }

                if (anot.OPD_USG400__c != null) {
                    flag = true ;
                }

                if ( anot.OPD_GW__c != null) {
                    flag = true ;
                }
                //  SWAG-BDN37X start
                //if ( anot.Submit_Customer_target__c) {
                //    flag = true ;
                //} 
                // SWAG-BDN37X end
            } else {
                if (oldMap.get(anot.Id).get('Target_amount_290Miro__c') != anot.Target_amount_290Miro__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_3D__c') != anot.Target_amount_3D__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_CHS400XZ__c') != anot.Target_amount_CHS400XZ__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_CV170__c') != anot.Target_amount_CV170__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_CV190__c') != anot.Target_amount_CV190__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_CV290__c') != anot.Target_amount_CV290__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_EUME2__c') != anot.Target_amount_EUME2__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_OERAW__c') != anot.Target_amount_OERAW__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_OTVS190__c') != anot.Target_amount_OTVS190__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_OTVS400__c') != anot.Target_amount_OTVS400__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_UCES3__c') != anot.Target_amount_UCES3__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_USG400__c') != anot.Target_amount_USG400__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Target_amount_GW__c') != anot.Target_amount_GW__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('Department_Budget_Sum_Price__c') != anot.Department_Budget_Sum_Price__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_290Miro__c') != anot.OPD_290Miro__c) {
                    flag = true ;
                }

                // SWAG-BC832V  CYF 更改也记录 更改者 start
                if (oldMap.get(anot.Id).get('Target_amount_CYF__c') != anot.Target_amount_CYF__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_amount_CYF__c') != anot.OPD_amount_CYF__c) {
                    flag = true ;
                }
                // SWAG-BC832V  CYF 更改也记录 更改者 end

                if (oldMap.get(anot.Id).get('OPD_3D__c') != anot.OPD_3D__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_CHS400XZ__c') != anot.OPD_CHS400XZ__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_CV170__c') != anot.OPD_CV170__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_CV190__c') != anot.OPD_CV190__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_CV290__c') != anot.OPD_CV290__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_EUME2__c') != anot.OPD_EUME2__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_OERAW__c') != anot.OPD_OERAW__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_OTVS190__c') != anot.OPD_OTVS190__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_OTVS400__c') != anot.OPD_OTVS400__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_UCES3__c') != anot.OPD_UCES3__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_USG400__c') != anot.OPD_USG400__c) {
                    flag = true ;
                }

                if (oldMap.get(anot.Id).get('OPD_GW__c') != anot.OPD_GW__c) {
                    flag = true ;
                }
                //SWAG-BDN37X start
                //if (oldMap.get(anot.Id).get('Submit_Customer_target__c') != anot.Submit_Customer_target__c) {
                //    flag = true ;
                //}
                // SWAG-BDN37X end
            }


            if (flag) {
                anot.TargetCustomerModifier__c = UserInfo.getUserId();
                anot.TargetCustomerMTIME__c = String.valueOf(Date.today());
            }

        }
    }

}