高章伟
2023-03-03 d8dc84a3d56df839895f1c417a4d9cbee763d262
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 测试类 AdvanceOpportunityTest
public with sharing class AdvanceOpportunityController {
    public AdvanceOpportunityController(ApexPages.StandardController stdController) {
        AdOpportunity = new Advance_Opportunity__c();
    }
    public Advance_Opportunity__c AdOpportunity{get; set;}
    public Boolean hasError { get; private set; }
    public String aoId {get; set;}
    public void init(){
        aoId = ApexPages.currentPage().getParameters().get('id');
        // 20220620 ljh  update SWAG-CFK9YX  start
        // List<Advance_Opportunity__c> aoList = [SELECT Id,MarketAdvance__c,AddOpportunity__c,BigContract__c,GradePro__c,AddPrice__c,Opportunity__c FROM Advance_Opportunity__c WHERE Opportunity__c = :aoId];
        List<Advance_Opportunity__c> aoList = [SELECT Id,MarketAdvance__c,KeepPushing__c,BigContract__c,GradePro__c,AddPrice__c,Opportunity__c FROM Advance_Opportunity__c WHERE Opportunity__c = :aoId];
        // 20220620 ljh  update SWAG-CFK9YX  edn
        if (aoList.size() == 0) {
            
        } else{
            AdOpportunity = aoList[0];
        }
    }
    public void save(){
        hasError = true;
        try {
            if (String.isBlank(AdOpportunity.Opportunity__c)) {
                AdOpportunity.Opportunity__c = aoId;
            }
            // AdOpportunity.Name = 'ceshi';
            upsert AdOpportunity;
            hasError=false;
        } catch (Exception ex) {
            system.debug('=====' + ex.getMessage());
            ApexPages.addMessages(ex);
        }
    }
}