liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
public with sharing class lexConsumApply_FromRACtl {
    public lexConsumApply_FromRACtl() {
 
    }
 
    @AuraEnabled
    public static List<FieldDefinition> fieldDefineApp(){
        try {
            List<FieldDefinition> rep = [Select QualifiedApiName, EntityDefinition.KeyPrefix, DurableId From FieldDefinition WHERE EntityDefinition.QualifiedApiName = 'Consum_Apply__c'];
            return rep;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
 
    //获取当前登录人的 id
    @AuraEnabled
    public static UserResult UserInfo_Owner() {
        UserResult result = new UserResult();
        ID myUserID = UserInfo.getUserId();
        try { 
            User tempUser =
                [select Id,isFormal_Stuff__c,FirstName,LastName from user where id = : myUserID ];
            result.id = tempUser.Id;
            result.isFormalStuff = tempUser.isFormal_Stuff__c;
            result.firstName = tempUser.FirstName == null ? '' : tempUser.FirstName;
            result.lastName = tempUser.LastName == null ? '' : tempUser.LastName;
        } catch (exception e) {
            
            result.result = e.getMessage();
        }
        return result;
    }
 
    @AuraEnabled
    public static InitData init(String recordId){
        InitData res = new initData();
        try {
            Rental_Apply__c rep = [select Id,demo_purpose2__c,Campaign__c,QIS_number__c,QISRepair__c,OPD__c,OPDPlan__c,Hospital__c,Strategic_dept__c,Account__c,ApplyPerson_Phone__c,Phone_number__c,Request_shipping_day__c,Loaner_medical_Staff__c,Loaner_medical_Staff__r.AWS_Data_Id__c,Loaner_medical_Staff__r.Name,AWS_Data_Id__c,Shipment_address__c,Dealer__c,direct_send__c,pickup_time__c,Loaner_received_staff__c,Loaner_received_staff_phone__c,Post_Code__c,direct_shippment_address__c from Rental_Apply__c where Id =: recordId]; //deloitte 2023/08/04 zhj 加上字段Loaner_medical_Staff__r.AWS_Data_Id__c,Loaner_medical_Staff__r.Name,AWS_Data_Id__c
            res.rentalApplyId = rep.Id;
            res.demoPurpose2 = '';
            res.rentalCampaign = rep.Campaign__c == null ? '' : rep.Campaign__c;
            res.rentalQISNumber = rep.QIS_number__c == null ? '' : rep.QIS_number__c;
            res.rentalQISRepair = rep.QISRepair__c == null ? '' : rep.QISRepair__c;
            res.rentalOPD = rep.OPD__c == null ? '' : rep.OPD__c;
            res.rentalOPDPlan = rep.OPDPlan__c == null ? '' : rep.OPDPlan__c;
            res.rentalHospital = String.isBlank(rep.Hospital__c) ? '' : rep.Hospital__c;
            res.rentalStrategicDept = rep.Strategic_dept__c == null ? '' : rep.Strategic_dept__c;
            res.rentalAccount = rep.Account__c == null ? '' : rep.Account__c;
            res.rentalApplyPersonPhone = rep.ApplyPerson_Phone__c == null ? '' : rep.ApplyPerson_Phone__c;
            res.rentalPhoneNumber = rep.Phone_number__c == null ? '' : rep.Phone_number__c;
            res.rentalRequestShippingDay = rep.Request_shipping_day__c;
            res.rentalLoanerMedicalStaff = rep.Loaner_medical_Staff__c == null ? '' : rep.Loaner_medical_Staff__c;
            res.rentalShipmentAddress = rep.Shipment_address__c == null ? '' : rep.Shipment_address__c;
            res.rentalDealer = rep.Dealer__c == null ? '' : rep.Dealer__c;
            res.rentalDirectSend = rep.direct_send__c == null ? '' : rep.direct_send__c;
            res.rentalPickupTime = rep.pickup_time__c;
            res.rentalLoanerReceivedStaff = rep.Loaner_received_staff__c == null ? '' : rep.Loaner_received_staff__c;
            res.rentalLoanerReceivedStaffPhone = rep.Loaner_received_staff_phone__c == null ? '' : rep.Loaner_received_staff_phone__c;
            res.rentalPostCode = rep.Post_Code__c == null ? '' : rep.Post_Code__c;
            res.rentalDirectShippmentAddress = rep.direct_shippment_address__c == null ? '' : rep.direct_shippment_address__c;
            res.rentalLoanerMedicalStaffName = rep.Loaner_medical_Staff__r.Name == null ? '' : rep.Loaner_medical_Staff__r.Name;//deloitee-zhj 20230804
            res.rentalLoanerMedicalStaffAWSDataId = rep.Loaner_medical_Staff__r.AWS_Data_Id__c == null ? '' : rep.Loaner_medical_Staff__r.AWS_Data_Id__c;//deloitee-zhj 20230804
            res.rentalApplyAWSDataId = rep.AWS_Data_Id__c == null ? '' : rep.AWS_Data_Id__c;//deloitee-zhj 20230804 
            if(rep.demo_purpose2__c == '试用(有询价)' || rep.demo_purpose2__c == '试用(无询价)'){
                res.demoPurpose2 = 'OPD试用';
            }else if(rep.demo_purpose2__c == '学会展会'){
                res.demoPurpose2 = '学会展会';
            }else if(rep.demo_purpose2__c == '索赔QIS'){
                res.demoPurpose2 = '索赔QIS';
            }
            return res;
        } catch (Exception e) {
            throw new AuraHandledException(e.getMessage());
        }
    }
    public class InitData{
        @AuraEnabled
        public String rentalApplyId;
        @AuraEnabled
        public String demoPurpose2;
        @AuraEnabled
        public String rentalCampaign;
        @AuraEnabled
        public String rentalQISNumber;
        @AuraEnabled
        public String rentalQISRepair;
        @AuraEnabled
        public String rentalOPD;
        @AuraEnabled
        public String rentalOPDPlan;
        @AuraEnabled
        public String rentalHospital;
        @AuraEnabled
        public String rentalStrategicDept;
        @AuraEnabled
        public String rentalAccount;
        @AuraEnabled
        public String rentalApplyPersonPhone;
        @AuraEnabled
        public String rentalPhoneNumber;
        @AuraEnabled
        public Date rentalRequestShippingDay;
        @AuraEnabled
        public String rentalLoanerMedicalStaff;
        @AuraEnabled
        public String rentalShipmentAddress;
        @AuraEnabled
        public String rentalDealer;
        @AuraEnabled
        public String rentalDirectSend;
        @AuraEnabled
        public Datetime rentalPickupTime;
        @AuraEnabled
        public String rentalLoanerReceivedStaff;
        @AuraEnabled
        public String rentalLoanerReceivedStaffPhone;
        @AuraEnabled
        public String rentalPostCode;
        @AuraEnabled
        public String rentalDirectShippmentAddress;
        @AuraEnabled
        public String rentalLoanerMedicalStaffName;//deloitee-zhj 20230804
        @AuraEnabled
        public String rentalLoanerMedicalStaffAWSDataId;//deloitee-zhj 20230804
        @AuraEnabled
        public String rentalApplyAWSDataId;//deloitee-zhj 20230804
    }
 
    public class UserResult {
        @AuraEnabled
        public string result;
        public UserResult( ) {
            result = 'Success';
        }
        @AuraEnabled
        public string id;
        @AuraEnabled
        public Boolean isFormalStuff;
        @AuraEnabled
        public string firstName;
        @AuraEnabled
        public string lastName;
    }
}