GWY
2022-05-21 a3460549533111815e7f73d6cef601a58031525d
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public with sharing class NewOrderController {
    public Id ordId {get;set;}
    public boolean errorflg {get;set;}
    public String errorMessage {get;set;}
 
    public String baseUrl { get; set; }
    public String rtUrl { get; set; }
 
    public String fileName { get; set; }
    public List<OrderItem> csv_activities {get;set;}
 
    public NewOrderController(ApexPages.StandardController controller) {
        this();
    }
 
    public NewOrderController() {
        baseUrl = URL.getSalesforceBaseUrl().toExternalForm();
        String path = URL.getCurrentRequestUrl().getPath();
        if (path.indexOf('/apex') > 0) {
            baseUrl += path.substring(0,path.indexOf('/apex'));
        } else if (path.indexOf('production/') > 0) {
            baseUrl += '/production';
        }
        rtUrl = System.currentPageReference().getParameters().get('retURL');
        if (rtUrl == null || rtUrl == 'null') {
            rtUrl = '';
        }
    }
 
    public void init () {
        ordId = System.currentPageReference().getParameters().get('Id');
 
        if (ordId != null) {
            csv_activities = [select Id, OrderId, PriceBookEntry.Product2.ProductCode, PriceBookEntry.Product2.Name, Quantity, Discount__c, Set__c from OrderItem where OrderId =: ordId];
        }
    }
 
    public PageReference csvExport() {
        if (fileName == null || fileName == '') {
            errorflg = true;
            errorMessage = '请输入配置导出文件名。';
            return null;
        }
 
        if (csv_activities.size() == 0) {
            errorflg = true;
            errorMessage = '合同没有产品配置。';
            return null;
        }
 
        PageReference pr = page.OrderCSVExport;
        return pr;
    }
}